[Tutor] OT - SQL methodology.

Liam Clarke cyresse at gmail.com
Tue Mar 22 07:20:30 CET 2005


Hi, 

This is a SQL query for the advanced db gurus among you (I'm looking at Kent...)

After I've run an insert statement, should I get the new primary key
(it's autoincrementing) by using PySQLite's cursor.lastrowid in a
select statement, or is there a more SQLish way to do this?

In the SQL books I've got, they always seem to have an optional select
statement on the end of inserts/updates, and I was thinking maybe I
could do it that way also, but I can't figure out a logical way of
putting

'select primary_key from foo where primary_key value > every other
primary_key value'

into SQL parlance. I figure this would be a safe way of doing it, as
the primary key is going to autoincrement ever upwards. Just don't
know if I can do it.

I'm trying to avoid firing off a select statement filled with the
exact same info as I just inserted/updated, as the only unique column
in my tables is the primary key.

Any assistance that can be rendered, would be gratefully accepted.

Regards, 

Liam Clarke

-- 
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.


More information about the Tutor mailing list