SQLMorph supports two database backends — SQLite and DuckDB — through aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dais-polymtl/sqlmorph/llms.txt
Use this file to discover all available pages before exploring further.
DatabaseHandler class that abstracts over both. You select a backend with the DBMS enum and pass a connection_params dict with the path to your database file. The handler instantiates the correct adapter, connects immediately, and exposes a uniform interface for running queries. This design means you can switch backends without changing any evaluation logic.
The DBMS enum
Configuring a backend
Passdb_params to your evaluation configuration using the DBMS enum and a db_path string.
- SQLite
- DuckDB
The BIRD benchmark ships SQLite databases. The default
DB_PATH in scripts/metrics_config.sh points to the California Schools database in the BIRD dev split.scripts/metrics_config.sh:
DatabaseHandler API
DatabaseHandler provides a consistent interface regardless of backend. The constructor connects immediately — you do not need to call connect_to_database() manually after instantiation.
A
DBMS enum member that selects the backend adapter. Raises ValueError for unsupported values.A dictionary of connection parameters for the chosen backend. Both SQLite and DuckDB require a
db_path key containing the path to the database file.Methods
connect_to_database()
Establishes the database connection by calling adapter.connect(). Called automatically by the constructor. Re-call it if you need to reconnect after an error.
run_query(query, return_cursor=False)
Executes a SQL query through the selected adapter.
- When
return_cursor=False(default), returns a tuple(column_names, rows)wherecolumn_namesis a list of strings androwsis a list of tuples. - When
return_cursor=True, returns the raw database cursor for advanced use cases.
is_connection_alive()
Runs SELECT 1 against the adapter and returns True if the connection is responsive, False otherwise.
close_connection()
Closes the underlying adapter connection and releases the file lock.
Adapter pattern
DatabaseHandler uses an adapter pattern internally. Each backend is implemented as a subclass of BaseAdapter:
SQLiteAdapter— wraps Python’s built-insqlite3module.DuckDBAdapter— wraps theduckdbPython package.
connect, run_query, close_connection) and accept an identical connection_params dict with a db_path key. You do not interact with adapters directly; DatabaseHandler selects and instantiates the correct one based on the DBMS value you provide.