Re: insert_id

Gerhard Häring <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Baptiste wrote:
> Hello,
> 
> I need to get back the id which sqlite has attributed (AUTOINCREMENT
> field) to the last recording done.
> TRAC mentions that feature :
> http://www.initd.org/tracker/pysqlite/changeset/9
> <http://www.initd.org/tracker/pysqlite/changeset/9> but when I use it, I
> have the error 'pysqlite2.dbapi2.Connection' object has no attribute
> 'insert_id'
> How can I do ? I'm using pysqlite 2.

That was a MySQLdb compatibility feature for pysqlite 1.x. What you're
looking for is the lastrowid property of the cursor object, which will work
for pysqlite 1.x, pysqlite 2.x and any other DB-API compliant database module.

- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFlTlqdIO4ozGCH14RAg/QAJ4ylzW6pK0+k+IscDdE+bggEgub3gCeLL1X
5MHMJ/fezb11zIM2usJl3ik=
=3foK
-----END PGP SIGNATURE-----
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.