DB API and thread safety

Matt Goodall matt at pollenation.net
Fri Jan 20 06:45:51 EST 2006


Robin Haswell wrote:
> Hey guys
> 
> I've been reading http://www.python.org/peps/pep-0249.html and I don't
> quite get what level of thread safety I need for my DB connections.
> 
> If I call db = FOOdb::connect() at the start of my app, and then every
> thread does it's own c = db.cursor() at the top, what level of thread
> safety do I need to avoid threads stepping on each other? Hopefully the
> answer to this question will get me oriented enough to understand the
> other options :-)

Assuming the cursor created in the thread is never accessed by another
thread then you need a dbapi module that supports threadsafety level 2 -
"threads may share the module and connections".

- Matt

-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.



More information about the Python-list mailing list