📃Configuration File
The configuration files are a set of companion files for each databases. They can be absent, and the database will take default values; if they are present, they indicate the parameters with which ws4sqlite must "treat" the database.
For file based dbs, the configuration file follows a naming convention: it must have the same path and filename of the db file, buit with a .yaml
extension instead of .db
. For memory based dbs, the config files can be specified in the --mem-db
commandline argument.
The configuration is in YAML format. A couple of examples that describe the entire set of configurations are as follows:
And:
A description of the fields (or areas) follows, with indication of the relevant lines in the example.
If an error occurs while parsing them, the application will exit with a status code of 1, after printing the error to stderr.
auth
auth
Lines 1-7 of #1, 1-3 of #2; object
Configuration for the authentication. See the relevant section.
disableWALMode
disableWALMode
Line 8 of #1; boolean
By default a database is opened in WAL mode. This line instructs ws4sqlite to open the database in rollback mode (i.e. non-WAL).
Under the hood, this is performed by using the journal_mode=WAL
pragma.
readOnly
readOnly
Line 9 of #1; boolean
If this boolean flag is present and set to true, the database will be treated as read-only. Only queries are allowed, that don't alter the database structure.
Under the hood, this is performed by using the query_only=true
pragma.
maintenance
maintenance
Lines 10-15 of #1; object
If present, instructs ws4sqlite on how to perform scheduled maintenance on this database. See the relevant section.
corsOrigin
corsOrigin
Line 4 of #2; string
If specified, it enables serving CORS headers in the response, and specifies the value of the Access-Control-Allow-Origin
header.
It can be set to *
.
Used to both configure the server to serve CORS headers and, when non-*
, restrict access to calls from a single, trusted web address.
storedStatements
and useOnlyStoredStatements
storedStatements
and useOnlyStoredStatements
storedStatements
: Lines 6-10 of #2; object
useOnlyStoredStatements
: Line 5 of #2; boolean
Stored Statements are a way to specify (some of) the statement/queries you will use in the server instead of sending them over from the client.
See the relevant section.
initStatements
initStatements
Lines 11-13 of #2; list of strings
When creating a database, it's often useful or even necessary to initialize it. This node allows to list a series of statement that will be applied to a newly-created database.
Notice that an in-memory database is always considered "newly created".
The statements are not run in a transaction: if one fails, the server will exit, but the file may remain created.
Last updated