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:
auth:mode:INLINEbyQuery:SELECT 1 FROM AUTH WHERE USER = :user AND PASSWORD = :passwordcorsOrigin:https://myownsite.comuseOnlyStoredStatements:truestoredStatements:-id:Q1sql:SELECT * FROM TEMP-id:Q2sql:INSERT INTO TEMP VALUES (:id, :val)initStatements:-CREATE TABLE AUTH (USER TEXT PRIMARY KEY, PASSWORD TEXT)-INSERT INTO AUTH VALUES ('myUser1', 'myCoolPassword')-CREATE TABLE TEMP (ID INT PRIMARY KEY, VAL TEXT)-INSERT INTO TEMP (ID, VAL) VALUES (1, 'ONE'), (4, 'FOUR')
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.
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
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
Lines 10-15 of #1; object
If present, instructs ws4sqlite on how to perform scheduled maintenance on this database. See the relevant section.
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: Lines 6-10 of #2; objectuseOnlyStoredStatements: 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.
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.