SQLAxe - SQL file splitter
Project description
README.md
SQLAxe
Eventually, SQLAxe will be a jq-like tool for manipulating SQL files.
However, for nom, SQLAxe is a command-line tool for splitting large SQL files into smaller, more manageable files based on the SQL statements they contain. It supports various SQL dialects and provides options for pretty printing and specifying the output directory.
db
d88b
ad88888ba ,ad8888ba, 88 d8'`8b
d8" "8b d8"' `"8b 88 d8' `8b
Y8, d8' `8b 88 d8YaaaaY8b
`Y8aaaaa, 88 88 88 d8''''''''8b
`"""""8b, 88 88 88 d8' 8b,`bb ,d8 ,adPPYba,
`8b Y8, "88,,8P 88 d8' `Y8, ,8P' a8P_____88
Y8a a8P Y8a. Y88P 88d8 )888( 8PP""""""'
"Y88888P" `"Y8888Y"Y8a 888888888 d8" "8b, "8b, ,
8P' `Y8 `"Ybbd8"'
Features
- Split large SQL files into smaller files based on target table.
- Support for multiple SQL dialects (e.g., MySQL, PostgreSQL)
- Option to specify the output SQL dialect
- Customizable output directory
- Pretty printing of SQL statements
Installation
-
Clone the repository:
git clone https://github.com/djberube/sqlaxe.git -
Install the required dependencies:
pip install -r requirements.txt
Usage
To split an SQL file using SQLAxe, run the following command:
python sqlaxe.py sql_file [--dialect DIALECT] [--output-dialect OUTPUT_DIALECT] [--output-directory OUTPUT_DIRECTORY] [--pretty]
Arguments:
sql_file: Path to the SQL file to be split.--dialect DIALECT: Input SQL dialect (default: mysql).--output-dialect OUTPUT_DIALECT: Output SQL dialect (defaults to the input dialect).--output-directory OUTPUT_DIRECTORY: Output directory (defaults to sqlaxe_INPUT_FILENAME, without the extension).--pretty: Enable pretty printing of SQL statements (default: off).
Example:
python sqlaxe.py path/to/your/file.sql --dialect mysql --output-dialect postgresql --output-directory output_files --pretty
Output
SQLAxe will create an output directory (if not specified, it will default to sqlaxe_INPUT_FILENAME) and generate separate SQL files for each SQL statement found in the input file. The output files will be named in the format NNNN_kind.sql, where NNNN is a four-digit section counter and kind is the table name or "general" if no table is found.
Dependencies
- Python 3.x
- sqlglot
- tqdm
Database Support
-
Tested with MySQL and PostgreSQL
-
Supports all the dialects from sqlglot; as of this writing, this includes:
- athena
- bigquery
- clickhouse
- databricks
- doris
- drill
- duckdb
- hive
- materialize
- mysql
- oracle
- postgres
- presto
- prql
- redshift
- risingwave
- snowflake
- spark
- spark2
- sqlite
- starrocks
- tableau
- teradata
- trino
- tsql
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 sqlaxe-0.0.3.tar.gz.
File metadata
- Download URL: sqlaxe-0.0.3.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e9f7cdeed11194b7a94eda4085ba0d4b932ab53d5e41c18001bb66926f09c2c
|
|
| MD5 |
164937761e0896f83d2f6221880bedad
|
|
| BLAKE2b-256 |
b89104b04ec3d54babe809f2d0afb2ee261ea7fcdb4bf2be2e9995eca1bcc820
|
File details
Details for the file sqlaxe-0.0.3-py3-none-any.whl.
File metadata
- Download URL: sqlaxe-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aee17e12f5abf15ea79e04c452d406a077fd78976f54d40c30ab947714778ff3
|
|
| MD5 |
0054f8a1b927389fe57d3623447b5981
|
|
| BLAKE2b-256 |
0a8e2d6c24182eb52760b05400ca85ceadc6790721b72020741841463a6ef7a4
|