Execute a SQL query. By default, this uses duckdb to execute the query. Any dataframes in the global namespace can be used inside the query. You can also pass a custom engine to execute queries against other databases.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/marimo-team/marimo/llms.txt
Use this file to discover all available pages before exploring further.
Usage
Signature
Parameters
The SQL query to execute.
Whether to display the result in the UI.
Optional SQL engine to use. Can be a SQLAlchemy, DuckDB, Clickhouse, Redshift, Ibis, or DB-API 2.0 compatible connection (including ADBC drivers). If
None, uses DuckDB.Returns
Any
The result of the query.
Supported Engines
- DuckDB (default): Automatically uses DuckDB if no engine is specified
- SQLAlchemy: Pass a SQLAlchemy engine or connection
- Ibis: Pass an Ibis connection
- Clickhouse: Pass a Clickhouse connection
- Redshift: Pass a Redshift connection
- DB-API 2.0: Any PEP 249 compatible connection
- ADBC: DB-API wrappers provided by ADBC drivers
Default Result Limit
You can set a default result limit using theMARIMO_SQL_DEFAULT_LIMIT environment variable. If set, queries without an explicit LIMIT clause will be limited to this many rows.