You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -477,15 +477,19 @@ For an example see [shaxbee/go-spatialite](https://github.com/shaxbee/go-spatial
477
477
478
478
Why is it racy if I use a `sql.Open("sqlite3", ":memory:")` database?
479
479
480
-
Each connection to :memory: opens a brand new in-memory sql database, so if
480
+
Each connection to `":memory:"` opens a brand new in-memory sql database, so if
481
481
the stdlib's sql engine happens to open another connection and you've only
482
-
specified ":memory:", that connection will see a brand new database. A
483
-
workaround is to use "file::memory:?mode=memory&cache=shared". Every
484
-
connection to this string will point to the same in-memory database.
482
+
specified `":memory:"`, that connection will see a brand new database. A
483
+
workaround is to use `"file::memory:?cache=shared"` (or `"file:foobar?mode=memory&cache=shared"`). Every
484
+
connection to this string will point to the same in-memory database.
485
+
486
+
Note that if the last database connection in the pool closes, the in-memory database is deleted. Make sure the [max idle connection limit](https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns) is > 0, and the [connection lifetime](https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime) is infinite.
0 commit comments