From: | Frank Broniewski <brfr(at)metrico(dot)lu> |
---|---|
To: | psycopg(at)postgresql(dot)org |
Subject: | Connection pooling and with statement |
Date: | 2013-08-23 10:03:57 |
Message-ID: | 5217338D.3080702@metrico.lu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
Hi,
I want to use psycopg2 in a WSGI environment. There you can have a
(configurable) number of processes and threads created that would be
accessing the database. Now I wonder what might be the best practice to
implement the pool. I don't think it is practicable to create the pool
in the WSGI application since this would create a number of pools for
each process and/or threads.
Or is the pool class simply not suitable for such a task?
Another question that occured to me is how I use the with statement with
the pool class:
I can do:
with pool.getconn() as conn:
with conn.cursor() as cursor:
# do stuff
Where do I need to call pool.putconn(conn)? How does the with statement
affect the connection? Is the with statement suitable for connection
pooling at all?
Many thanks,
Frank
--
Frank BRONIEWSKI
METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN
tél.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu
From | Date | Subject | |
---|---|---|---|
Next Message | Samuel PHAN | 2013-08-23 11:58:10 | Re: Connection pooling and with statement |
Previous Message | Daniele Varrazzo | 2013-08-13 18:28:02 | Re: psycopg with pg_filenode |