duckdb / sqlite_scanner

DuckDB extension to read and write to SQLite databases
https://duckdb.org/docs/extensions/sqlite
MIT License
203 stars 21 forks source link

Impossible to export sqlite to duckdb keeping constraints. "information_schema.table_constraints" waiting for a memory use. #115

Open Victordeleusse opened 1 week ago

Victordeleusse commented 1 week ago

What happens?

I try to ATTACH a sqlite db but impossible to export constraints as primary and foreign keys.

To Reproduce

Working on an attached sqlite database :

con = duckdb.connect()
con.execute("ATTACH 'california_schools.sqlite' as cs (TYPE sqlite)")
con.execute("USE cs")
res = con.execute("SELECT * FROM information_schema.table_constraints").fetchall()
print(res)

Here an error occured

CatalogException                          Traceback (most recent call last)

Cell In[187], line 1

----> 1 res = con.execute("SELECT * FROM information_schema.table_constraints").fetchall()

      2 print(res)

CatalogException: Catalog Error: Table with name table_constraints does not exist!

Did you mean "memory.information_schema.table_constraints"?

LINE 1: SELECT * FROM information_schema.table_constraints

When adding it and using it as requiered, the return list is empty whereas constraints keys well exist in database, so it seems that the constraints are not export from sqlite to DuckDB (as the command ALTER TABLE is still not functionnal in DuckDB it seems make sens). So how to face off this issue ? And how to allow exporting an sqlite db to a duckdb one keeping constraints and metadata ?

Thank you.

OS:

x86_64

DuckDB Version:

latest

DuckDB Client:

Python

Hardware:

No response

Full Name:

Victor de Leusse

Affiliation:

42

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

I have tested with a stable release

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

Not applicable - the reproduction does not require a data set

Did you include all code required to reproduce the issue?

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

szarnyasg commented 1 week ago

Thanks! Here's a plain SQL reproducer on sakila.db:

ATTACH 'sakila.db' as cs (TYPE sqlite);
USE cs;
SELECT * FROM information_schema.table_constraints;