A pure Python library to execute SQL queries against SQL dump files using DuckDB.
Project description
sqldump-engine
A Python library and CLI tool to query SQL dump files (MySQL, PostgreSQL) directly using SQL, without requiring a running database server.
Powered by DuckDB and sqlglot.
Features
- Multi-dialect Support: Handles MySQL and PostgreSQL dumps.
- Smart Transpilation: Converts dialect-specific DDL (like
AUTO_INCREMENTorSERIAL) to DuckDB-compatible SQL. - High Performance: Uses DuckDB's columnar engine for fast queries.
- PostgreSQL COPY Support: Efficiently handles bulk data exported via the
COPYcommand. - CLI Interface: Query dumps directly from your terminal.
Installation
pip install -e .
Usage
CLI
# Query a MySQL dump
sqldump-engine query --dump tests/sample_mysql.sql "SELECT * FROM users"
# Query a PostgreSQL dump
sqldump-engine query --dump tests/sample_postgres.sql --dialect postgres "SELECT * FROM users"
Python Library
from sqldump_engine import SqlDumpEngine
engine = SqlDumpEngine()
engine.load_dump("path/to/dump.sql", dialect="mysql")
# Get results as a Pandas DataFrame
df = engine.fetch_df("SELECT username, email FROM users WHERE id > 10")
print(df)
Limitations
- Complex DDL: Views, triggers, and stored procedures are currently ignored.
- Dialect Parity: While most standard types are mapped, esoteric vendor-specific types might fallback to
TEXT. - Large multi-row INSERTs: Very large
INSERTstatements in MySQL (many megabytes) are supported but might hit memory limits depending on the environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqldump_engine-0.1.0.tar.gz
(5.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqldump_engine-0.1.0.tar.gz.
File metadata
- Download URL: sqldump_engine-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccfa7450ee68e2b6fbc425baed9b432f3466d18e7f5e50f275b1d35f98ac8dc0
|
|
| MD5 |
99aa31abb348e84844381e62a6e61ec8
|
|
| BLAKE2b-256 |
d46660135860c0a845142330d71442fd386f477844d3f018feeb5e8c687b7af5
|
File details
Details for the file sqldump_engine-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sqldump_engine-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1e12538691af31e72743e425cea582746a4af7d20c2da96de8164c813a0c62c
|
|
| MD5 |
ce3180825dd57ee7e6d4ce070496e1b9
|
|
| BLAKE2b-256 |
dfa6a85db05413b0a02cfb6ff16284e80374a33c4d2ad97863fa5c18bb2871fd
|