Skip to content

database/sql: Memory databases intermittently lose data #188

Answered by ncruces
ncruces asked this question in Q&A
Discussion options

You must be logged in to vote

No, this is not a bug in the driver, or SQLite.

When you open a "connection" with database/sql you're actually opening a pool of connections. But SQLite :memory: are private to a single SQLite connection. So each query, or statement, may be run against the same or a different :memory: database, and you have no control over this. If you, by accident, get a new empty database, your table (or whatever data) will be missing.

This is a known issue that affects all Go SQLite drivers, this driver is not special in that regard. However, other drivers may offer you the option to share a :memory: database across connections by using shared cache. This is a poor solution that would not work with thi…

Replies: 1 comment

Comment options

ncruces
Nov 25, 2024
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by ncruces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
1 participant