π¦Cheat Sheet
Commandline
ws4sql
--bind-host 0.0.0.0 \ # Optional
--port 12321 \ # Optional
--db ~/file1.yaml \ # Configuration file/pointer for a db
--quick-db myFile.db \ # Single-file SQLite db, without configuration
--serve-dir myDir # Serve static resources from a filesystem directoryConfiguration file
database:
type: SQLITE # SQLITE or DUCKDB. If omitted, defaults to SQLITE
inMemory: false # The db is a memory one? If omitted, defaults to false
path: ".../test.db" # The db file path.
id: test # If omitted and !inMemory, calculates it from the file name
disableWALMode: false # If type = SQLITE, disables WAL mode
readOnly: false # If true, doesn't allow modifications to db
# All the following first-level elements are optional (auth, disableWALMODE, ...)
auth:
mode: HTTP # INLINE or HTTP
customErrorCode: 499 # HTTP Code when auth fails; can be customized if the default (401) is not optimal
# Specify one of byQuery or byCredentials
# The query must have :user and :password for SQLite or $user/$password for DuckDB
byQuery: SELECT 1 FROM AUTH WHERE USER = :user AND PASSWORD = :password
# Credentials can be multiple, with different <user>, and the password may be BCrypt or cleartext
byCredentials:
- user: myUser
hashedPassword: "$2b$12$.." # BCrypt hash of the password
schedTasks: # Multiple tasks are possible
- schedule: "0 0 * * *" # Cron format without seconds (m h d m wd)
atStartup: false # This (as true) or schedule must be present
doVacuum: true
doBackup: true
backupTemplate: ~/temp_%s.db # A placeholder %s must be present, it will be replaced with yyyyMMdd_HHmm
numFiles: 3 # Backup files to keep
statements: # SQL Statements to execute at every scheduled run
- DELETE FROM myTable WHERE tstamp < CURRENT_TIMESTAMP - 3600
- ...
- atStartup: true # Either this must be true, or a schedule must be present
doVacuum: true
corsOrigin: https://myownsite.com # Access-Control-Allow-Origin
useOnlyStoredStatements: true # Doesn't allow free-text SQL in the request, but only stored statements
storedStatements:
- id: Q1 # Refer as #Q1 in requests
sql: SELECT * FROM TEMP
- id: Q2 # Refer as #Q2 in requests
sql: INSERT INTO TEMP VALUES (:id, :val)
initStatements: # These statements will be executed when a db is created
- 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')Request
URL
Headers
Body
Response
General Error (400, 401, 404, 500)
400, 401, 404, 500)Success (200)
200)Last updated