Re: cur.close() when con.close() is next line or not?

Gerhard Häring <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Nikos Kouremenos wrote:
> Hello, in the pysqlite samples you don't close cursor before closing
> connection (pure logic suggets cursor gets closed by connection
> closing).
> 
> BUT, when cur.execute('UPDATE whatever') and then con.close() I was
> getting a TraceBack with unfinished something.

Certainly you're talking about


pysqlite2.dbapi2.OperationalError: Unable to close due to unfinalised
statements

> I looked it up in the ML, and everyone suggested cur.close(), which
> yes fixed the problem.

Yes, this was necessary with pysqlite 2.0.x versions. If you use later
pysqlite versions like 2.1.3 or later this problem does not exist any more.

> So, now I ask: cur.close() is a good idea to have, and why if missing
> [as everywhere] it's okay until we do an UPDATE
> 
> shouldn't be the behaviour more consisting? (my vote is that we don't
> need cur.close() no matter what we do, this is python).

Just upgrade to a more recent pysqlite version - I recommend the latest one :-)

-- Gerhard
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.