sqlite3 bug??
Gerhard Häring
gh at ghaering.de
Tue Jun 19 12:10:56 EDT 2007
Hyuga wrote:
> On Jun 17, 9:16 am, mark carter <m... at privacy.net> wrote:
>> Should I also explicitly close the cursor and connection, or is that
>> taken care of "automagically"?
>>
>
> Somebody correct me if I'm wrong, but I'm pretty sure that the Cursor
> and Connection objects properly clean themselves up when deallocated
> (when their reference count reaches 0), so not explicitly closing them
> isn't a terrible thing. [...]
That's correct for pysqlite, and probably for all other DB-API modules
too. If you have a client-server database, it's nicer to close the
database connection if you don't need it any longer in order to free up
resources on the server, of course.
> In fact, I have code in which references to a db connection are
> passed around, so I have to be careful about explicitly closing the
> connection, lest it be in use by some other method somewhere. Maybe
> people will frown on this, but it's not uncommon.
I don't think I've ever explicitly closed a cursor object when
programming to the DB-API myself.
-- Gerhard
More information about the Python-list
mailing list