Commit Graph

14 Commits

Author SHA1 Message Date
Luis Lavena 84857724c1
Automatically set PRAGMAs using connection query params (#85)
* Automatically set PRAGMAs using connection query params

Introduce the flexibility to adjust certain PRAGMAs of the SQLite3
connection without having to hardcode those in your codebase (and wait
for compilation).

This allows applications to use `DATABASE_URL` to dynamically fine tune
their SQLite3 configuration.

The change complements `#setup_connection` that offers, via code, the
option to perform queries on setup of each connection.

Only a few PRAGMAs necessary to allow more performant concurrent reads
and reduce write locking.

These pragmas are detected and combined in a single SQL string to reduce
to 1 the number of calls to `sqlite3_exec` C function.

There is no validation of supplied values as SQLite3 automatically
ignores incorrect values for these pragmas.

Closes #84

References:
- https://www.sqlite.org/pragma.html

* Simplify PRAGMA mapping and detection

No longer prefix PRAGMAS with `_`, so the mapping between the real
SQLite3 pragmas and the usage in the URI is more direct.

Use macros instead of case to detect pragmas from URI params and return
those as NamedTuple.

* Update README.md

---------

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>
2023-02-18 17:06:09 -03:00
Ryan Westlund 985bfa2d7c
Fix timestamp reading issue (#68) 2021-02-28 14:18:08 -03:00
Brian J. Cardiff d9f916a598
Update README.md for dynamic args (#53) 2020-01-14 10:29:58 -03:00
Brian J. Cardiff ae84010c28 Use text instead of string as sqlite type
Ref: crystal-lang/crystal-db#71
2017-11-13 10:59:59 -03:00
Brian J. Cardiff 9784573152 Add Bool support
* change specs to not use #scalar since it does not have expected type information.
* refactor Time spec
2016-12-14 13:52:12 -03:00
Brian J. Cardiff 710ac1d170 update links 2016-06-27 14:25:55 -03:00
Brian J. Cardiff c9b54c3da0 update readme 2016-06-27 14:08:21 -03:00
Brian J. Cardiff 1d52f93879 remove old code 2016-02-18 18:52:49 -03:00
Jonne Haß 652308db5f update readme for shards 2015-11-28 14:07:42 +01:00
Jonne Haß 2f2ae4dd41 enable travis 2015-11-28 14:05:10 +01:00
Ary Borenszweig 5b08d2f48b Remove travis for now... 2015-06-30 23:22:41 -03:00
Ary Borenszweig d6cfeee85b Added .travis.yml 2015-06-30 22:51:34 -03:00
Ary Borenszweig d62185867b Documentation and some refactors 2015-03-12 21:08:01 -03:00
Ary Borenszweig d96255d766 Initial commit 2015-03-12 20:31:46 -03:00