1

I have a WSGI application. At the beginning of the Python script (before construction of the WSGI handler) I set up a database connection in a globally accessed area. Whenever a request needs to use the database, it just imports the file and grabs this global object.

The database in particular is PostgreSQL and I am using psycopg, which is DB API 2.0 'Level 2 Thread Safe'.

Do I have to worry about different request transactions ruining eachother? Each connection uses its own cursor. A little confused.

Thank you

throw
  • 11
  • 2
  • I'm looking for a similar answer. I want to use `python-tds` (aka `pytds`) to access MS SQL databases, so I don't need to depend on FreeTDS, but this pure python TDS protocol implementation is not supported by SQLAlchemy for example, which offers a connection pool. So what I'm basically looking for is how to implement such a pool for DBAPI2.0 compatible drivers if one does not exist yet. – Paul-Sebastian Manole Mar 11 '16 at 13:47
  • You might want to read similar questions like [this one](http://stackoverflow.com/questions/98687/what-is-the-best-solution-for-database-connection-pooling-in-python). – Paul-Sebastian Manole Mar 11 '16 at 13:50

0 Answers0