Fix SQLite connection starts without foreign key enforcement #798 and Transactions #732 #803
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #798 and #732 for SQLite in lapis/db/sqlite.lua
NOTE: I need help correcting lapis/db/sqlite.moon, because I am not familiar with MoonScript. Also if there is an issue with my coding style or naming conventions, please change if necessary...
Currently there is no way to issue persistent PRAGMA statements for connections. Also there is no way to have transaction support for multiple SQL statements, since sqlite.lua uses lsqlite3
db:nrows
, which only allows a single statement in SQLite.Added functionality for setting SQLite pragma commands needed for all connections (foreign_keys, busy_timeout, etc.) in
connect
function of sqlite.lua. To use this feature, config file would need to have a connection_pragma_defaults table like this (key is pragma command, value is pragma value):Also added the following functions
exec
-allowing the use of lsqlite3db:exec
function, which allows multiple statements and transactionsexec_scalar
- utility function for easily retrieving a single valueprepare
- allowing the use of db:prepare for prepared statementsFor instance, if you have the config file setup like the example above: