Commit graph

38 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
Ryan Westlund
55b8399d7e
Enable REGEXP by connecting Crystal's stdlib Regex (#62) 2020-11-11 15:00:40 -03:00
Brian J. Cardiff
4b4441bb37 Code cleanup due to Crystal >= 0.28.0 2019-06-06 12:36:16 -03:00
Brian J. Cardiff
2bfda2aa13 Fix Time.new deprecation warning
Enforce Crystal 0.28.0 or later
2019-06-04 17:54:24 -03:00
Brian J. Cardiff
c621a9b701
Upgrade to Crystal 0.28.0 (#38) 2019-04-18 15:58:02 -03:00
Brian J. Cardiff
c1f214d695
Upgrade time usage for crystal 0.25.0 (#34) 2018-06-18 10:26:32 +02: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
Tom Richards
e6d5ad33c3 Multi-step exec support (#27) 2017-09-14 15:51:25 -03:00
Brian J. Cardiff
5eb85a98c6 Update to crystal-db ~> 0.4.1
Replace driver_spec for db/spec.
Fix read(T?) for T = Int32, Flaot32, Time, Bool..
Fixes #19
2017-04-10 14:09:22 -03:00
Brian J. Cardiff
b43a12fc92 Add spec for DB.connect
Update to crystal-db ~> 0.4.0
2017-03-21 15:46:57 -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
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
46709eab00 add spec for transactions and nested transactions (#12) 2016-12-14 12:27:43 -03:00
Brian J. Cardiff
261f17ad21 add spec for using the connection pool 2016-10-19 01:44:34 -03:00
Ary Borenszweig
1e8de9a2b4 Implement https://github.com/crystal-lang/crystal-db/pull/9 2016-06-28 14:04:27 -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
Brian J. Cardiff
497379ff81 extend sqlite with time (as text) support. 2016-06-22 16:17:47 -03:00
Brian J. Cardiff
d65575cd77 update Slice(UInt8) to Bytes 2016-06-22 14:13:44 -03:00
Brian J. Cardiff
c8d5acceae Make sure queries (insert and query) work with any type 2016-06-22 00:45:00 -03:00
Ary Borenszweig
135f33d9ea Updated to Crystal 0.18.0 2016-06-15 12:05:12 -03:00
Ary Borenszweig
eb8e4a6962 Simplify flags creation and usage 2016-03-17 10:58:47 -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
1d52f93879 remove old code 2016-02-18 18:52:49 -03:00
Brian J. Cardiff
503868f434 update to last db design 2016-02-18 18:52:49 -03:00
Brian J. Cardiff
dd5c10ba6e column types
update to connection_string
remove Driver.quote
2016-02-18 18:52:48 -03:00
Brian J. Cardiff
2e6e6ed7e5 add insert/select per type specs
add last_insert_id
add Driver.quote
2016-02-18 18:52:48 -03:00
Brian J. Cardiff
add75d86bf update to refactored api
refactor specs
2016-02-18 18:52:48 -03:00
Brian J. Cardiff
5266a7e7b3 column_count, column_name, close statement 2016-02-18 18:52:48 -03:00
Brian J. Cardiff
63f98d18d1 add blob support 2016-02-18 18:52:48 -03:00
Brian J. Cardiff
82f68ed6cf arguments support 2016-02-18 18:52:48 -03:00
Brian J. Cardiff
efa010e2ad migrate to crystal std db. keeping old code side by side 2016-02-18 18:52:48 -03:00
Brian J. Cardiff
ee0bc75e3a Update to crystal 0.10.0 2016-01-28 21:06:40 -03:00
Ary Borenszweig
5ab80b9f36 Updated to Crystal 0.8.0 2015-09-21 14:55:13 -03:00
Jonne Haß
22d83727df Ensure close of statement 2015-09-06 18:55:21 +02: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