DB Pool
Diez B. Roggisch
deets at nospam.web.de
Tue Jul 22 09:29:40 EDT 2008
bcurtu wrote:
> Hi,
>
> I use MySQLdb lib to access my DB, because I want to opttimize my sql
> queries. The application I'm working on has quite a few traffic load,
> so I want to minimize the time of creating/destroying cursors:
>
> My typical code is sth like:
>
> cursor=con.cursor()
> cursor.execute(sql)
> all= cursor.fetchall()
> cursor.close()
>
> So, the question is... how can I minimize this cost? I was thinking on
> Connection Pools, but I didn't find any good documentation or sample.
> Any idea?
What has the above (getting *cursors* from a given connection) to do with
connection-pooling?
I'm not sure what the actual costs of creating a cursor are (might well be
that these are neglibel) but why don't you stop closing the cursor and just
re-use it?
Connection pooling is of course useful - frameworks such as SQLAlchemy and
SQLObject do that for you, if used proper.
Diez
More information about the Python-list
mailing list