On Tuesday 13 February 2007 18:39, johnf wrote: > On Tuesday 13 February 2007 18:29, johnf wrote: > > On Tuesday 13 February 2007 17:40, Ed Leafe wrote: > > > On Feb 13, 2007, at 8:15 PM, johnf wrote: > > > > Yes please do and please take into consideration that psycopg uses > > > > connection > > > > pooling for every cursor created. > > > > > > Can you explain that better? In the dbapi, you start with a > > > connection object, and from that you get cursors. All cursors created > > > from a single connection object share that connection. > > > > > > Uwe is asking for multiple connection objects. Are you saying that > > > if you create multiple connection objects using psycopg, they will > > > actually be the same connection underneath? > > > > > > > > > -- Ed Leafe > > > -- http://leafe.com > > > -- http://dabodev.com > > > > See my reply to Uwe. > > I got this from the website: > psycopg is different from the other database adapter because it was > designed for heavily multi-threaded applications that create and destroy > lots of cursors and make a conspicuous number of concurrent INSERTs or > UPDATEs. Every open Python connection keeps a pool of real (UNIX or TCP/IP) > connections to the database. Every time a new cursor is created, a new > connection does not need to be opened; instead one of the unused > connections from the pool is used. That makes psycopg very fast in typical > client-server applications that create a servicing thread every time a > client request arrives. > > So as I read above two cursors two connections. I decided to ask the author of psycopg below is his response. > conn=psycopg2.connect("dbname='foo' user='dbuser' password='mypass'") > cur1 = conn.cursor() > cur2 = conn.cursor() > > Will be two connections one for each of the cursors. > > Is this correct???
Not anymore (that was true in psycopg1 and only withserialized cursors). Right now there is a 1-1 mapping betwen connection objects and physical connections to the backend. cursors are light-weight objects to be used to execute queries and to access result sets. That's all. federico -- John Fabiani _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
