Charles Mills wrote:
I am trying to create a table after creating a select statement which selects records from an existing table. Is this possible? I get a SQLITE_LOCKED / "database table is locked" error when I attempt this.
In psuedo code the logic is as follows:
select_stmt = db.execute("SELECT * FROM people")
# use some, but not all of the rows in select_stmt
create_stmt = db.execute("CREATE TABLE other (a,b)") # error: database table is locked
Why does this happen?
Anyway around this?
You must finalize select_stmt before running again db.execute
Right. I have an instance where I would like to keep the select_stmt _open_ (or not finalized) while I create a new table. Is this possible?
While you are reding the DB, you can't update it, sqlite support many simultaneous readers but only one write; so you can't create a new table while your select statement is running.
I thin you must do somthing like this:
select_stmt = db.execute("SELECT * FROM people") # use some, but not all of the rows in select_stmt sqltorun += "CREATE TABLE other (a,b);" select_stmt.finalize() create_stmt = db.execute(sqltorun)
Paolo