Skip to content

default_connection: When closed, default_connection() returns the closed connection #16135

@paultiq

Description

@paultiq

What happens?

Related to #13442, some oddities occur when using default_connection().

The main thing is: when the default_connection is closed, the closed connection continues to return. I would've expected it to reset as if no connection, and return a new connection on next call.

Basically, anything that closes a default_connection leads to a bad state. How should things work if the default_connection is closed? Anyway, I think #13442 (comment) is probably on point, default_connection leads to weirdness.

To Reproduce

import duckdb
with duckdb.default_connection() as con:
    con.execute("select version()")
with duckdb.default_connection() as con:
    con.execute("select version()")

| ConnectionException: Connection Error: Connection already closed!

OS:

Windows

DuckDB Version:

1.2.0

DuckDB Client:

Python

Hardware:

No response

Full Name:

Paul T

Affiliation:

Iqmo

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a nightly build

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions