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
@@ -251,7 +252,7 @@ Every Connection comes equipped with its own serial queue for statement executio
251
252
252
253
If you maintain multiple connections for a single database, consider setting a timeout (in seconds) and/or a busy handler:
253
254
254
-
```swift
255
+
```swift
255
256
db.busyTimeout =5
256
257
257
258
db.busyHandler({ tries in
@@ -265,6 +266,33 @@ db.busyHandler({ tries in
265
266
> _Note:_ The default timeout is0, so if you see `database is locked` errors, you may be trying to access the same database simultaneously from multiple connections.
266
267
267
268
269
+
### Connection Pools
270
+
271
+
Connection pools use SQLite WAL mode to allow concurrent reads and writes, which can increase performance. Connection pools are created similar to connections:
272
+
273
+
``` swift
274
+
let pool =tryConnectionPool("path/to/db.sqlite3")
275
+
```
276
+
277
+
Writes are done inside of a readWrite block:
278
+
279
+
``` swift
280
+
pool.readWrite { connection in
281
+
try db.run(users.insert(email <-"[email protected]", name <-"Alice"))
SQLite.swift comes with a typed expression layer that directly maps [Swift types](https://developer.apple.com/library/prerelease/ios/documentation/General/Reference/SwiftStandardLibraryReference/) to their [SQLite counterparts](https://www.sqlite.org/datatype3.html).
0 commit comments