-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add utils functions to import and export DuckDB DBs
- Loading branch information
1 parent
fc04ddd
commit 56cdb96
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Export the DuckDB database schema and data to a directory to be imported later | ||
by the user. This is preferred over version controlling the DB file itself | ||
due to merge conflicts and other issues that arise with binary files. | ||
""" | ||
import duckdb | ||
|
||
# The directory to get the DB file from. | ||
export_from = "resources/portfolio.db" | ||
# The directory to export the DB to. | ||
export_to = "resources/portfolio_data" | ||
|
||
conn = duckdb.connect(export_from) | ||
conn.execute(f"EXPORT DATABASE '{export_to}'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Import the DuckDB database schema and data from a directory where it was | ||
previously exported by a user. This is preferred over version controlling the | ||
DB file itself due to merge conflicts and other issues that arise with binary | ||
files. | ||
""" | ||
import duckdb | ||
|
||
# The directory to import the DB file from. | ||
import_from = "resources/portfolio_data" | ||
# The directory to load the DB into. | ||
import_to = "resources/portfolio.db" | ||
|
||
conn = duckdb.connect(import_to) | ||
conn.execute(f"IMPORT DATABASE '{import_from}'") |