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 55b8399d7e
Enable REGEXP by connecting Crystal's stdlib Regex (#62) 2020-11-11 15:00:40 -03:00
Tom Richards a95182be08 Add error codes to LibSQLite3::Code (#36) 2018-10-05 11:53:19 -03:00
Ryan Breen 790d0ded8b Bytes argument properly bind blob, not text (#28) 2017-09-19 16:48:05 -03:00
Benoist 616af3ba1d better closing checks (#23) 2017-05-29 15:20:32 -03:00
Hinrik Örn Sigurðsson bbed6256a6 Make SQLite3::Connection#dump copy all DB pages (#16)
An issue with bindings caused less than total pages to be copied.
2017-01-17 16:57:27 -03:00
Ary Borenszweig 0396d63771 Updated to Crystal 0.19.0 2016-09-03 18:41:31 -03:00
Ary Borenszweig 84e1eed991 Fixed type references 2016-07-11 15:24:37 -03:00
Brian J. Cardiff 881ef79893 Merge master changes into db branch.
Refactor flags, add option to dump from one database connection to another.

Merge commit '135f33d9eac82c63a48b14942c8eff647c070410' into db

# Conflicts:
#	spec/database_spec.cr
#	src/sqlite3/lib_sqlite3.cr
#	src/sqlite3/result_set.cr
#	src/sqlite3/statement.cr
2016-06-23 17:27:58 -03:00
Ben Jolitz c7260cd2cb Seperate out LibSqlite3 enums as they do not change
This allows LibSQLite3 to be changed without breaking
anyone's code
2016-03-16 17:17:56 -07:00
Ben Jolitz fa220a1c4c Initial support/tests for SQLite flags and db dump
This commit adds a pass through for specifying SQLite3 flags. This is
an absolute requirement for being able to create in-memory DB
representations.
2016-03-14 19:53:51 -07:00
Brian J. Cardiff 503868f434 update to last db design 2016-02-18 18:52:49 -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