Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify? #2

Open
ltalirz opened this issue Dec 12, 2024 · 0 comments
Open

simplify? #2

ltalirz opened this issue Dec 12, 2024 · 0 comments

Comments

@ltalirz
Copy link

ltalirz commented Dec 12, 2024

## Get sqlite Names
conn.sql("USE __other")
tables = [i[0] for i in conn.sql("SHOW tables").fetchall()]
print(f"{len(tables)} tables found(s)")
conn.sql(f"USE {db_name}")
# Create tables
for table in tables:
print(f"Create duckdb table {table}")
conn.sql(f"CREATE TABLE {table} AS select * FROM __other.{table}")
conn.sql(f"DETACH __other")
conn.close()
end_time = time.perf_counter()
execution_time = (end_time - start_time) * 1000

This seems overly complicated. What about something like

# Attach the DuckDB database (named)
conn.execute(f"ATTACH '{duckdb_file}' AS duck_db;")
# Attach the SQLITE database (named)
conn.execute(f"ATTACH '{sqlite_db}' as sqlite_db;")

conn.execute("COPY FROM DATABASE sqlite_db TO duck_db;")
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

No branches or pull requests

1 participant