0

I'm using an SQLite database as a substitute for a very large in-memory data structure, so I have a simple single-threaded process repeatedly reading from and writing to the database through a single database connection. (I'm using the SQLite C API directly from within a C++ application.) If I perform a write operation, can I later read that data back in without first performing a COMMIT operation? That is, would it work to execute "BEGIN TRANSACTION" when I open the file, do all of my data processing (interleaving reads and writes), then execute "COMMIT" just before closing the file?

I was hoping that OS-level file buffers would allow for this sort of behaviour (e.g., see "Are Unix reads and writes to a single file atomically serialized?"), or perhaps some sort of internal SQLite buffering would come into play, but couldn't find this addressed specifically anywhere.

Community
  • 1
  • 1
  • possible duplicate of [in sqlite3, can a select succeed within a transaction of insert?](http://stackoverflow.com/questions/376773/in-sqlite3-can-a-select-succeed-within-a-transaction-of-insert) – Graham Borland Jun 27 '12 at 12:40
  • Hmm, good catch (although I wish the answers provided some sort of reference). I tried searching for "sqlite alternate read write single process" and a few other variations on Google and Stack Overflow before asking, but didn't come across that answer. – Ian Mackenzie Jun 27 '12 at 12:51

0 Answers0