[DB-SIG] Optional DB API Extensions

Andy Dustman andy@dustman.net
25 Oct 2001 14:09:33 -0400


On Thu, 2001-10-25 at 13:52, brian zimmer wrote:
> What happens in the case of:
> 
> cur.execute("insert into x values (?, ?)", [(a, b), (c, d)])
> 
> I presume the .lastrowid is the value of the insert with (c, d)? 

Actually, with MySQLdb you need:

cur.executemany("insert into x values (%s, %s)", [(a, b), (c, d)])

(execute is deprecated by DB-API 2.0 for multi-row inserts)

But yes, it's the last row id, i.e. the last one inserted.

-- 
Andy Dustman         PGP: 0x930B8AB6
    @       .net     http://dustman.net/andy
You can have my keys when you pry them from my dead, cold neurons.