Configuration#
SQLThunder uses YAML configuration files to manage database connection settings across SQLite, MySQL, and PostgreSQL. This allows clean separation of credentials and connection logic from your code.
General Structure#
At a minimum, each config file must include the database type and required connection fields for that database. Optional fields such as SSL certificates, timeouts, and PostgreSQL options can be added for advanced use cases.
Supported Fields#
Field |
Description |
Required |
|---|---|---|
|
|
✅ |
|
Path to SQLite file (or |
✅ (sqlite) |
|
Database username |
✅ (mysql/pgsql) |
|
Database password |
✅ (mysql/pgsql) |
|
Database host |
✅ (mysql/pgsql) |
|
Port (default: 3306 for MySQL, 5432 for PG) |
optional (mysql/pgsql) |
|
Database name |
✅ (mysql/pgsql) |
|
PostgreSQL SSL mode ( |
optional (pgsql) |
|
Path to CA certificate (SSL) |
optional (mysql/pgsql) |
|
Path to client certificate (SSL) |
optional (mysql/pgsql) |
|
Path to client private key (SSL) |
optional (mysql/pgsql) |
|
Connection timeout in seconds |
optional (mysql/pgsql) |
|
MySQL read timeout |
optional (mysql) |
|
MySQL write timeout |
optional (mysql) |
|
PostgreSQL application name |
optional (pgsql) |
|
PostgreSQL connection options |
optional (pgsql) |
SQLite Example#
db_type: "sqlite"
path: "data/my_database.sqlite"
For in-memory databases:
db_type: "sqlite"
path: ":memory:"
Basic MySQL Example#
db_type: "mysql"
user: "admin"
password: "secure123"
host: "localhost"
port: 3306
database: "trades"
MySQL Example with SSL and Options#
db_type: "mysql"
user: "admin"
password: "secure123"
host: "localhost"
port: 3306
database: "trades"
connect_timeout: 15
read_timeout: 60
write_timeout: 60
ssl_ca: "~/certs/ca.pem"
ssl_cert: "~/certs/client-cert.pem"
ssl_key: "~/certs/client-key.pem"
PostgreSQL Example with Advanced Options#
db_type: "postgresql"
user: "postgres"
password: "secure123"
host: "db.prod.local"
port: 5432
database: "analytics"
connect_timeout: 10
ssl_mode: "verify-ca"
ssl_ca: "~/certs/ca.pem"
ssl_cert: "~/certs/client-cert.pem"
ssl_key: "~/certs/client-key.pem"
application_name: "sqlthunder-worker"
pg_options: "-c statement_timeout=30000 -c search_path=myschema"
You can pass multiple pg_options like setting a custom search path or statement timeout.
Notes#
Paths like
~/certs/ca.pemare automatically expanded to absolute paths.Missing or malformed fields will raise helpful errors at runtime.
SSL certificates are only validated if explicitly provided.
PostgreSQL
ssl_modeoverrides psycopg2preferdefault behavior (e.g.require,verify-ca,verify-full).