A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: restore DuckDB 2.0 default database and schema discovery (#11515)
Shahmir Varqhacbc387e1c133
diff --git a/marimo/_sql/engines/duckdb.py b/marimo/_sql/engines/duckdb.pyindex b0e8f8d1ad..49bdffd479 100644--- a/marimo/_sql/engines/duckdb.py+++ b/marimo/_sql/engines/duckdb.py@@ -149,7 +149,8 @@ class DuckDBEngine(SQLConnection[Optional["duckdb.DuckDBPyConnection"]]):duckdb.DuckDBPyConnection, self._connection or duckdb)with self._install_connection(connection):- row = connection.sql("SELECT CURRENT_DATABASE()").fetchone()+ rows = connection.sql("SELECT CURRENT_DATABASE()").fetchall()+ row = rows[0] if rows else Noneif row is not None and row[0] is not None:return str(row[0])return None@@ -165,7 +166,8 @@ class DuckDBEngine(SQLConnection[Optional["duckdb.DuckDBPyConnection"]]):duckdb.DuckDBPyConnection, self._connection or duckdb)with self._install_connection(connection):- row = connection.sql("SELECT CURRENT_SCHEMA()").fetchone()+ rows = connection.sql("SELECT CURRENT_SCHEMA()").fetchall()+ row = rows[0] if rows else Noneif row is not None and row[0] is not None:return str(row[0])return Nonediff --git a/tests/_sql/test_duckdb.py b/tests/_sql/test_duckdb.pyindex 70d25249a3..994e838bc1 100644--- a/tests/_sql/test_duckdb.py+++ b/tests/_sql/test_duckdb.py@@ -207,6 +207,29 @@ def test_duckdb_engine_get_databases_no_conn() -> None:engine.execute("DROP TABLE test")[email protected](not HAS_DUCKDB, reason="duckdb not installed")[email protected]("use_connection", [True, False])+def test_default_catalog_discovery(use_connection: bool) -> None:+ import duckdb++ with duckdb.connect() as connection:+ engine = DuckDBEngine(connection if use_connection else None)+ query_connection = connection if use_connection else duckdb++ assert engine.get_default_database() == "memory"+ assert query_connection.sql("SELECT 42").fetchall() == [(42,)]+ assert engine.get_default_schema() == "main"+ assert query_connection.sql("SELECT 42").fetchall() == [(42,)]+ assert [+ schema.name+ for schema in engine.get_schemas(+ database=None,+ include_tables=False,+ include_table_details=False,+ )+ ] == ["main"]++@pytest.mark.skipif(not HAS_DUCKDB, reason="duckdb not installed")def test_get_current_database_schema() -> None:import duckdb