![]() ![]() A new read won't block/fail unless the write process has started (there is an EXCLUSIVE/PENDING lock held) and a write won't start until all outstanding reads are complete and it can obtain an EXCLUSIVE lock (this is not true for WAL but the transaction isolation is still the same). See locking in SQLite for the definitive information.Īll transactions in SQLite are SERIALIZABLE (see the read_uncommitted pragma for one small exception). These apply to SQLite 3.x using Journaling and may or may not apply to different configurations - WAL is slightly different but I am not familiar with it. Did I forget a step?Īdditional notes regarding some comments in this post/answer about transactions in SQLite. The "Domain stuff" is domain specfic and other than reading values from the recordset doesn't access the database. If I remove the transaction everything works as expected. Sql += "Update X Set Z = 'foo' Where Y " While (MemberVariable > 0 & ranges.Read()) ![]() Transaction = conn.BeginTransaction(IsolationLevel.ReadCommitted) Also fails transaction = conn.BeginTransaction() SQLiteTransaction transaction = conn.BeginTransaction() SQLiteCommand command = new SQLiteCommand(conn) SQLiteConnection conn = OpenNewConnection() LogEvent("Exception raised when opening connection to. SQLiteConnection conn = new SQLiteConnection() Ĭonn.ConnectionString = ConnectionString // private static SQLiteConnection OpenNewConnection() At this point I commit the transaction, however none of the updates are being performed on the database. After I'm done reading the recordset, I close the recordset and run the updates. I begin a transaction, read the rows, and while iterating on the recordset build up a string of update statements. During this operation all other users of the database need to be locked out to avoid bad reads. I modified your example to use always insertData wrapper.For an application we are developing we need to read n rows from a table and then selectively update those rows based on domain specific criteria. ![]() As I understand SQLite, you have no control of different parallel "connections" as you have in PostgreSQL, so you probably need to wrap all your communication with DB. The biggest problem with your code IMHO is that you try to write to DB from different locations. My answer is based on quick study of node-sqlite3. Is there a better approach? How do you deal with this problem?Īt first, I would like to state that I have no experience with SQLite.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |