SQLite3 and lastrowid
ian.g.kelly at gmail.com
Tue Nov 16 21:54:37 CET 2010
On Nov 16, 1:00 pm, fuglyducky <fuglydu... at gmail.com> wrote:
> Before I added the second table I could simply run
> 'print(cursor.lastrowid)' and it would give me the id number. However,
> with two tables I am unable to do this.
It would help if you would show the code where you're trying to do
this. Without your actual code to look at, we can't tell you why it
> Does anyone know if there is a way to reference one table or another
> to get lastrowid?
cursor.lastrowid is always in reference to the last query executed by
the cursor, not in reference to a table. If you don't capture the
value, and then you execute another query on the same cursor, the
previous value of cursor.lastrowid no longer exists. If you need it
now, then either you should have captured it when you had the chance,
or you should not have executed another query on the same cursor.
But perhaps this is not what you're actually trying to do. I can't
tell, because I haven't seen the code.
More information about the Python-list