[DB-SIG] Python db programming conventions

M.-A. Lemburg mal at egenix.com
Wed Oct 20 22:26:20 CEST 2010

python + sqlite3 wrote:
> Vernon, 10x for the detailed reply.
> I understand from your answer that each SQL statement should have it's own
> cursor so in my case,
> since the db contains 5 tables, creating it will require 5 cursors.

You can reuse cursors to run multiple commands. However, if you need
to access the result sets of e.g. 5 different queries at the same
time, then you do indeed have to open 5 cursors to keep open the
result sets.

> The parametrized queries will become handy when I'll write the INSERT and
> SELECT part of the code.

Here's a short introduction to the DB-API and the concepts:


I also gave a slightly longer talk in German at the recent
DZUG Tagung 2010 in Dresden:


Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, Oct 20 2010)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the DB-SIG mailing list