Re: [pysqlite] sqlite3 - implicit close() when cursor object reclaimed?
Gerhard Häring <[email protected]> Sat, 06 Sep 2008 20:14:26 +0200
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Skip Montanaro wrote:
> Given this method:
>
> def iterkeys(self):
> c = self._conn.cursor()
> c.execute("select key from dict order by key")
> return (e[0] for e in c)
>
> where self._conn is a sqlite3 connection (I'm using the code in Python 3.0b3
> at the moment), is the cursor properly closed when the returned genexp is
> freed? I saw no mention of Cursor.close in the Python 2.6 sqlite3 docs. In
> the _sqlite/cursor.c file I see that at least part of what
> pysqlite_cursor_close does is executed in pysqlite_cursor_dealloc, but not
> everything. Shouldn't pysqlite_cursor_close be called from
> pysqlite_cursor_dealloc?
Which is the difference you see between pysqlite_cursor_close and
pysqlite_cursor_dealloc that I don't see?
Both call pysqlite_statement_reset(). pysqlite_cursor_close additionally
has (helpful to not shoot yourself in the foot with older SQLite
versions) a check that it was called from the same thread that the
cursor was created from. But that's it from what I saw in the Python 3.0
sources.
- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFIwsiCdIO4ozGCH14RAmhuAKCybKC79z3IRy516rMUqrfD1OSAlwCfZotv
dHWuqxsGnTkp+P42NcH0k9s=
=8zmJ
-----END PGP SIGNATURE-----