I do not know if this is a regression or not, but it seems like it is as I now need to handle different error cases depending on sqlite version. In 3.38 it looks like the error occurs during query compilation (perhaps) and is a generic error And furthermore seems the code is SQLITE_CONSTRAINT. The error code returned by SQLite 3.35 does not occur until one starts stepping through the results. To quote the pysqlite3-binary package maintainer which I use for 3.38.0 on Linux (given discussion here): 'user_id integer not null references users(id), 'Ĭonn.execute('insert into users (username) values (?)', ('u1',))Ĭonn.execute('insert into tweets (user_id, message) values (?, ?)', (1, 't1'))Ĭursor = conn.execute('insert into tweets (user_id, message) values (?, ?) returning id, user_id, message', (2, 'tx'))Įxtra code to cause IntegrityError on 3.35.5: cursor.fetchall() RETURNING will give an OperationalError.Įxample source code that gives the OperationalError error on 3.38.0: import sqlite3Ĭonn.execute('create table users (id integer not null primary key, username text)')Ĭonn.execute('create table tweets (id integer not null primary key, ' For 3.38.0, the INSERT will give an IntegrityError and the INSERT. On the Python side, an INSERT and INSERT RETURNING will give an IntegrityError for 3.35.5. I am seeing different errors for a foreign key conflict (no record exists) for an INSERT versus an INSERT. I use the Python sqlite3 bindings for sqlite, and on Windows I have 3.35.5 and on Linux I have 3.38.0.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |