Skip to content

Marimo complains on closed (secondary) DuckDB-Connections #7111

@baikal

Description

@baikal

Describe the bug

Using a secondary DuckDB-Connection and closing it (explicitly or by context manager style) triggers a

--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\xxxxxxxx\AppData\Local\uv\cache\archive-v0\dXPKCyVSQXrwxwttuG29f\Lib\site-packages\marimo\_data\get_datasets.py", line 154, in _get_databases_from_duckdb_internal
    tables_result = connection.execute(query).fetchall()
                    ~~~~~~~~~~~~~~~~~~^^^^^^^
_duckdb.ConnectionException: Connection Error: Connection already closed!

Shouldn't that (get_datasets.py) somehow check if that connection is available and skip it if not?

Will you submit a PR?

  • Yes

Environment

Details
{
  "marimo": "0.17.7",
  "editable": false,
  "location": "C:/Users/xxxxxxxx/AppData/Local/uv/cache/archive-v0/N3ybeShgMKuwL_3BESmsA/Lib/site-packages/marimo",
  "OS": "Windows",
  "OS Version": "11",
  "Processor": "Intel64 Family 6 Model 166 Stepping 1, GenuineIntel",
  "Python Version": "3.13.9",
  "Locale": "de_CH",
  "Binaries": {
    "Browser": "--",
    "Node": "--"
  },
  "Dependencies": {
    "click": "8.3.0",
    "docutils": "0.22.3",
    "itsdangerous": "2.2.0",
    "jedi": "0.19.2",
    "markdown": "3.10",
    "narwhals": "2.10.2",
    "packaging": "25.0",
    "psutil": "7.1.3",
    "pygments": "2.19.2",
    "pymdown-extensions": "10.16.1",
    "pyyaml": "6.0.3",
    "starlette": "0.50.0",
    "tomlkit": "0.13.3",
    "typing-extensions": "missing",
    "uvicorn": "0.38.0",
    "websockets": "15.0.1"
  },
  "Optional Dependencies": {
    "loro": "1.8.2"
  },
  "Experimental Flags": {}
}

Code to reproduce

# /// script
# requires-python = ">=3.13"
# dependencies = [
#     "duckdb==1.4.1",
#     "pyarrow==22.0.0",
# ]
# ///

import marimo

__generated_with = "0.17.7"
app = marimo.App(width="medium")


@app.cell
def _():
    import duckdb
    return (duckdb,)


@app.cell
def _(duckdb):
    dk_conn=duckdb.connect()
    res1=dk_conn.sql("select 1 as one").fetch_arrow_table()
    dk_conn.close()
    return (res1,)


@app.cell
def _(duckdb):
    with duckdb.connect() as dc:
        res2=dc.sql("select 2 as two").fetch_arrow_table()
    return (res2,)


@app.cell
def _(res1, res2):
    res1, res2
    return


if __name__ == "__main__":
    app.run()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions