Inserting into multiple tables with multiple rows into a table in sqlite -


i want insert 2 tables @ time.

this needs done way.

insert single row 1 table, auto incremented primary key , insert multiple rows other table, using primary key value got first table reference.

what best way this?

sqlite has built-in last_insert_rowid() function, return value change after next insertion.

you have read value in program, , insert manually:

db.execute("insert people(name) values (?)", ["joe"]) id = db.last_insert_rowid db.execute("insert pets(owner, name) values (?,?)", [id, "fluffy"]) db.execute("insert pets(owner, name) values (?,?)", [id, "spot"]) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -