0

Hi I have this silly question, but I want to be sure. I have created a database based on sqlite3. I trigger the commit() after 1000k operations so I will not have too much disk I/O. When I seek data on the database, will the select query search only in the database file or will it check the uncommited data too ?

Thanks.

Dima Tisnek
  • 11,241
  • 4
  • 68
  • 120
bill
  • 728
  • 3
  • 6
  • 15
  • 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) – Maxime Lorant May 18 '14 at 12:30
  • http://stackoverflow.com/a/376799/705086 to be precise though, on the same connection you see uncomitted data. on another connection you don't, which is why another process doesn't see it either. – Dima Tisnek May 18 '14 at 17:45

2 Answers2

1

Transactions allow isolation and atomicty regarding other users of the database. Any changes you make are visible in your own connection immediately.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • So uncommited data are visible inside my program . In case that the database is public others won't see those data , right ? – bill May 18 '14 at 12:34
  • While they won't be visible to other programs using the database, they will only be visible to your program inside the same connection that issued the INSERT statements. Other simultaneous connections in your own program won't see the data. Not a problem if you're using only a single database connection but potentially confusing if you are using multiple connections. – Larry Lustig May 18 '14 at 12:42
0

If you are using the same SQLite connection for reading as you are for writing the database, then the effects of the writing will be visible to the reader, as expected.

If you are using different connections -- even within a single thread -- for reading and writing, the reader will not see uncommitted writes to the database unless you go to rather significant lengths to allow it to do so.

Larry Lustig
  • 49,320
  • 14
  • 110
  • 160