-
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.
- Loading branch information
1 parent
d42fb7c
commit b76af35
Showing
3 changed files
with
63 additions
and
4 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
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
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,43 @@ | ||
import argparse | ||
import logging | ||
|
||
import duckdb | ||
|
||
# Set up logging | ||
logging.basicConfig( | ||
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" | ||
) | ||
|
||
|
||
def export_database(database_filename, export_directory): | ||
""" | ||
Export a DuckDB database to a specified directory. | ||
Args: | ||
database_filename (str): The filename of the DuckDB database to export. | ||
export_directory (str): The directory to save the exported database. | ||
""" | ||
logging.info(f"Connecting to database: {database_filename}") | ||
conn = duckdb.connect(database_filename) | ||
|
||
logging.info(f"Exporting database to directory: {export_directory}") | ||
conn.execute(f"EXPORT DATABASE '{export_directory}' (FORMAT PARQUET)") | ||
|
||
logging.info("Database export completed successfully") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Export a DuckDB database.") | ||
parser.add_argument( | ||
"--database_filename", | ||
help="The filename of the DuckDB database to export.", | ||
default="dbt_bgcflow.duckdb", | ||
) | ||
parser.add_argument( | ||
"--export_directory", | ||
help="The directory to save the exported database.", | ||
default="./exported_database", | ||
) | ||
args = parser.parse_args() | ||
|
||
export_database(args.database_filename, args.export_directory) |