Skip to content

Fix: Motherduck config and add session_name - #1399

Open
Donnype wants to merge 2 commits into
Mause:mainfrom
Donnype:motherduck-session-name-config
Open

Fix: Motherduck config and add session_name#1399
Donnype wants to merge 2 commits into
Mause:mainfrom
Donnype:motherduck-session-name-config

Conversation

@Donnype

@Donnype Donnype commented Aug 3, 2026

Copy link
Copy Markdown

The issue

The session_name (previously session_hint) can only be set during connection initialisation. A SET after connecting fails with a "can only be set during initialization". This adds the "motherduck_session_name" and (deprecated) "motherduck_session_hint" to the core config of MotherDuck.

I also noticed that the other config keys were missing the required motherduck_ namespacing as well, so I updated those config keys. This didn't work before:

uvx --with duckdb-engine --with 'duckdb==1.5.4' python -c "from sqlalchemy import create_engine; create_engine('duckdb:///md:?attach_mode=single').connect()"

Gives:

[...]
sqlalchemy.exc.ProgrammingError: (_duckdb.InvalidInputException) Invalid Input Error: The following options were not recognized: attach_mode
(Background on this error at: https://sqlalche.me/e/20/f405)

And

uvx --with duckdb-engine --with 'duckdb==1.5.4' python -c "from sqlalchemy import create_engine; create_engine('duckdb:///md:?motherduck_attach_mode=single').connect()"

Gives:

[...]
sqlalchemy.exc.DBAPIError: (_duckdb.Error) setting 'motherduck_attach_mode' can only be set during initialization
(Background on this error at: https://sqlalche.me/e/20/dbapi)

After this change, this should work: duckdb:///md:?motherduck_session_name=alice&motherduck_attach_mode=single.

Donnype added 2 commits July 31, 2026 17:02
motherduck_session_name (and its deprecated alias motherduck_session_hint)
can only be set during connection initialization; applying it via SET after
connecting to an md: database fails with "can only be set during
initialization". Add both keys to the MotherDuck connect-time config list
so they can be passed through the URL query string, e.g.
duckdb:///md:?motherduck_session_name=alice.
…ixed

The connect-time config whitelist listed attach_mode and saas_mode, which
are md: connection-string parameters ("md:db?attach_mode=single"), not
duckdb settings. duckdb.connect() rejects them with "The following options
were not recognized", so those whitelist entries never worked:

    duckdb:///md:?attach_mode=single
    -> Invalid Input Error: The following options were not recognized: attach_mode

while the real setting name fell through to a post-connect SET and failed:

    duckdb:///md:?motherduck_attach_mode=single
    -> setting 'motherduck_attach_mode' can only be set during initialization

Use the actual setting names (motherduck_attach_mode, motherduck_saas_mode)
so both can be passed through the URL query string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant