Database module & multithreading

John Nagle nagle at animats.com
Sat Mar 10 12:40:17 EST 2007


Michael Bentley wrote:
>>
>> Thanx for this pointer buddy! I have done my homework. Some Database
>> modules are not actively maintained some modules  does not work with
>> Python 2.5. At this moment I am using Sqlite3 which is pretty fast but
>> it dosent allow me to use multi threading so which database module is
>> better in terms of multithreading
> 
> 
> Actually, I think sqlite3 just requires that each thread have its own  
> connection and cursor.

     SQlite is thread-safe but not concurrent; only one thread
at a time can be doing database updates to a database.  The whole
database is locked during each transaction that changes the database.
However, multiple reads (SELECTs) can be done simultaneously.  So
mostly-read databases can still get some concurrency going.

     The question is, how many transactions per second do you
need to process?  This sounds like someone writing their first
database program, not someone who needs thousands of transactions
per second and has a farm of dedicated servers to support them.
Any of the usual choices should work: SQLite, MySQL, or Postgres.

     As for "some modules not being maintained", it really is sad
that MySQLdb is kind of behind.  If you're running Windows and need
MySQL, you're either stuck with Python 2.4, or have to get a 2.5 version
from a World of Warcraft guild.  The source version of MySQLdb, though,
does build properly on Red Hat Fedora Core 6 for Python 2.5.

				John Nagle



More information about the Python-list mailing list