Thanks, Roger.  Your second suggestion does the trick.  The first, however,
returns:  <sqlite3.Cursor object at 0x012CC1A0>.  Can you explain why?
Thanks again.

Karl

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Roger Binns
Sent: Sunday, October 26, 2008 9:32 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] last_insert_rowid() syntax

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Karl Lautman wrote:
> Can someone point out to me the syntax error in the following?  I've
omitted
> the set-up code for brevity, but cur is a cursor with a connection to the
> database.  Thanks.  
> 
>>>> x = cur.execute('last_insert_rowid()')

last_insert_rowid() is a function just like min, max, hex, length etc.
See http://www.sqlite.org/lang_corefunc.html

So to get the value you need to use:

  cur.execute("select last_insert_rowid()")

It looks like you are using pysqlite so you can just do this which does
the same thing behind the scenes:

  x=cur.lastrowid

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkkFREsACgkQmOOfHg372QQGcQCg5mJ6n7KY7lIF33nXuj10zQDX
698AnRfN3ZplfMYf4SvT3vzfsg40kUJV
=q4tC
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to