Configuration file reference¶
Semolina reads connection settings from a TOML file, by default
.semolina.toml in the current directory.
File location¶
create_engine() looks for .semolina.toml in the
working directory. Pass a different path with the config_path argument:
from semolina import create_engine
engine = create_engine(
"default", config_path="config/warehouse.toml"
)
File structure¶
Each named connection lives under [connections.<name>]. The type field
is required and determines which backend fields are available.
[connections.default]
type = "snowflake"
account = "xy12345.us-east-1"
user = "alice"
# password comes from SNOWFLAKE_PASSWORD
database = "ANALYTICS"
warehouse = "COMPUTE_WH"
[connections.analytics]
type = "databricks"
host = "adb-123456.azuredatabricks.net"
http_path = "/sql/1.0/warehouses/abc123"
# token comes from DATABRICKS_TOKEN
catalog = "main"
[connections.local]
type = "duckdb"
database = "/data/analytics.db"
Use create_engine("analytics") to select a connection by name; the default
is "default".
Environment variables¶
A field the section leaves out is read from the backend’s prefixed environment
variable: SNOWFLAKE_ for Snowflake, DATABRICKS_ for Databricks, DUCKDB_
for DuckDB, followed by the field name in upper case. A committed file can therefore
omit its secret, as the example above does for password and token. A value
in the section wins over the environment. One field breaks the pattern: schema
is read from an unprefixed SCHEMA variable on Snowflake and Databricks, so set
it in the file. semolina codegen also reads a .env
file; see How to configure codegen credentials.
Which section is read¶
Two callers read this file, and they select a section by different rules:
Caller |
Section read |
|---|---|
The name you pass, defaulting to |
|
|
|
|
No section. The path comes from |
For Snowflake and Databricks, a file with only [connections.default] therefore serves
your application but makes semolina codegen exit 2. Define both sections if you use
both. See How to configure codegen credentials.
Common fields¶
These fields are accepted by all connection types:
typestring, requiredBackend identifier. One of
"snowflake","databricks", or"duckdb".pool_sizeinteger, default 5 (DuckDB in-memory: 1)Number of connections to keep in the pool. A file-backed DuckDB database defaults to 5 like the other backends;
database = ":memory:"defaults to 1 and rejects anything higher.max_overflowinteger, default 3Extra connections allowed beyond
pool_sizeunder load.timeoutinteger, default 30Seconds to wait for a connection from the pool before raising
sqlalchemy.exc.TimeoutError. Note that this is SQLAlchemy’s class, not the builtinTimeoutError.recycleinteger, default 3600Seconds after which a connection is recycled (closed and replaced).
pre_pingboolean, default falseTest a pooled connection for liveness before handing it out, replacing it if the check fails.
accountstringSnowflake account identifier (e.g.
xy12345.us-east-1).userstringUsername.
passwordstringPassword for basic authentication.
databasestringDefault database.
schemastringDefault schema.
warehousestringSnowflake virtual warehouse.
rolestringSnowflake role.
regionstringSnowflake region, if not embedded in the account identifier.
hoststringExplicit hostname (alternative to account-derived URI).
portintegerConnection port.
protocolstring"http"or"https".
Authentication
auth_typestringAuthentication method. One of
auth_jwt,auth_ext_browser,auth_oauth,auth_mfa,auth_okta,auth_pat,auth_wif. Omit for basic (user/password) authentication.private_key_pathstringFile path to a PKCS1 or PKCS8 private key. Mutually exclusive with
private_key_pem.private_key_pemstringInline PEM-encoded PKCS8 private key. Mutually exclusive with
private_key_path.private_key_passphrasestringPassphrase to decrypt an encrypted PKCS8 key.
jwt_expire_timeoutstringJWT expiry duration (e.g.
"300ms","1m30s").oauth_tokenstringBearer token for
auth_oauth.okta_urlstringOkta server URL, required when
auth_type = "auth_okta".identity_providerstringIdentity provider for
auth_wif.
Timeouts and behaviour
login_timeoutstringLogin retry timeout duration.
request_timeoutstringRequest retry timeout duration.
client_timeoutstringNetwork roundtrip timeout duration.
tls_skip_verifyboolean, default falseDisable TLS certificate verification.
ocsp_fail_open_modeboolean, default trueAllow connection when OCSP check fails.
keep_session_aliveboolean, default falsePrevent session expiry during long operations.
app_namestringApplication identifier sent to Snowflake.
disable_telemetryboolean, default falseDisable Snowflake usage telemetry.
cache_mfa_tokenboolean, default falseCache MFA token for subsequent connections.
store_temp_credsboolean, default falseCache ID token for SSO.
Databricks connections can be configured in two ways: a full URI, or decomposed fields. Use one or the other, not both.
URI mode
uristringFull connection string:
databricks://token:<token>@<host>:443/<http-path>.
Decomposed mode
hoststringWorkspace hostname (e.g.
adb-123456.azuredatabricks.net).http_pathstringSQL warehouse HTTP path (e.g.
/sql/1.0/warehouses/abc123).tokenstringPersonal access token.
Common fields
catalogstringDefault Unity Catalog.
schemastringDefault schema.
OAuth authentication
auth_typestringOAuth auth type. One of
"OAuthU2M"(browser-based) or"OAuthM2M"(service principal). Omit for PAT authentication.client_idstringOAuth M2M service principal client ID.
client_secretstringOAuth M2M service principal client secret.
databasestring, default “:memory:”Path to a DuckDB database file, or
":memory:"for an in-memory database.read_onlyboolean, default falseOpen the database in read-only mode.
Note
DuckDB enforces pool_size=1 for in-memory databases. Setting
pool_size > 1 with database = ":memory:" raises a
ValidationError. Use a file path for concurrent connections.
See also¶
How to configure your warehouse backend – write your first
.semolina.tomland the connection settings each warehouse takesDuckDB – DuckDB connection setup
How to manage engines and connection pools – build an engine and tune its pool
create_engine()– API reference