Vivien Malerba wrote:
Hi!
In a single process, I open two connections (C1 and C2) to the same
database (this is actually a corner case which could happen) and the
following sequence of operations fail:
1- on C1 execute "CREATE table actor (...)" => Ok
2- on C1 execute "SELECT * FROM actor" => Ok
3- on C2 execute "SELECT * FROM actor" => error because table "actor"
does not exist.
Is there a way to make this sequence of operations work
What SQLite version/API are you using?
ISTR this was fixed some time ago - you need to use sqlite3_prepare_v2()
instead of sqlite3_prepare().
AIUI, pre the v2 API, connections cache a copy of the schema and aren't
aware of changes made by other connections, so your case would result in
a schema changed error. The caller would detect this and re-prepare and
re-execute the statement. Since this was a common error case the _v2 API
was created. It stores a copy of the statement's SQL and automatically
re-prepares it if a schema change is encountered.
I don't know offhand when this was added, but I assume it was ages ago
because it works with Python's wrapper and that uses SQLite v3.3.4.
>>> import sqlite3
>>> c1=sqlite3.Connection("c:\\fred")
>>> c2=sqlite3.Connection("c:\\fred")
>>> c1.execute("create table t(a,b,c)")
<sqlite3.Cursor object at 0x00D94560>
>>> c1.execute("select * from t")
<sqlite3.Cursor object at 0x00D94500>
>>> c1.execute("select * from t").fetchall()
[]
>>> c2.execute("select * from t").fetchall()
[]
>>> sqlite3.sqlite_version
'3.3.4'
>>>
Martin
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------