-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
Labels
Description
What happens?
I have a little helper to clone a duckdb but only for select schemas (gist).
The relevant bit of code is this:
with duckdb.connect(str(source_path), read_only=True) as source_conn:
available_schemas = [
row[0]
for row in source_conn.execute(
"SELECT schema_name FROM information_schema.schemata"
).fetchall()
]
valid_schemas = [s for s in schemas_to_copy if s in available_schemas]
with duckdb.connect(str(target_path)) as target_conn:
for schema in valid_schemas:
tables = [
row[0]
for row in source_conn.execute(
"SELECT table_name FROM information_schema.tables WHERE table_schema = ?",
[schema],
).fetchall()
]
target_conn.execute(f"CREATE SCHEMA IF NOT EXISTS {schema}")
for table in tables:
target_conn.execute(f"ATTACH '{source_path}' AS source_db")
target_conn.execute(
f"CREATE TABLE {schema}.{table} AS SELECT * FROM source_db.{schema}.{table}"
)
target_conn.execute("DETACH source_db")Since v1.5.0, i am encountering a locking error:
Failed to copy schemas Binder Error: Unique file handle conflict: Cannot attach "source_db" - the database file "/Users/paul/demo/demo.duckdb" is already attached by database "demo"
I thought this was related to #19171 but that got fixed in 1.4.2
To Reproduce
Requires typer.
To run the gist:
python minimize_duckdb.py -v -i source.duckdb -o mini.duckdb -s desired_schemaOS:
docker container, debian, also tested on macos and windows
DuckDB Package Version:
1.5.0
Python Version:
3.12
Full Name:
Paul Spitzner
Affiliation:
linkFISH Consulting
What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.
I have not tested with any 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 to reproduce the issue?
- Yes, I have
Reactions are currently unavailable