Re: [pysqlite] sqlite3 - implicit close() when cursor object reclaimed?
[email protected] Sat, 6 Sep 2008 15:22:11 -0500
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
>> Shouldn't pysqlite_cursor_close be called from
>> pysqlite_cursor_dealloc?
Gerhard> Which is the difference you see between pysqlite_cursor_close and
Gerhard> pysqlite_cursor_dealloc that I don't see?
Gerhard> Both call pysqlite_statement_reset(). pysqlite_cursor_close
Gerhard> additionally has (helpful to not shoot yourself in the foot
Gerhard> with older SQLite versions) a check that it was called from the
Gerhard> same thread that the cursor was created from. But that's it
Gerhard> from what I saw in the Python 3.0 sources.
That's what I was referring to.
So is this code safe/correct even though I don't explicitly call c.close()?
If I call close() here the genexp only yields a single value.
def iterkeys(self):
c = self._conn.cursor()
c.execute("select key from dict order by key")
return (e[0] for e in c)
Skip