This is a simple python CLI tool to organize .sql files. This is a useful tool for my work, but I decided to share it as a project example
Project description
____ ___ _ ___ _
/ ___| / _ \| | / _ \ _ __ __ _ __ _ _ __ (_)_______ _ __
\___ \| | | | | | | | | '__/ _` |/ _` | '_ \| |_ / _ \ '__|
___) | |_| | |___ | |_| | | | (_| | (_| | | | | |/ / __/ |
|____/ \__\_\_____| \___/|_| \__, |\__,_|_| |_|_/___\___|_|
|___/
By: Steven Rudenko (steven.gucum@gmail.com)
This project is inspired by a problem I had at work where I would get billion seperate .sql files to execute one by one and had to manually copy them into a one worksheet. This CLI tool automates this process. It also sorts the files based on chosen strategies (I will introduce more in the future). Ofcourse this tool can be used with any file format, but since this is manly used for my SQL problem - I named it SQL Organizer :D
Installation
- Windows
pip install sql-organizer
Examples
Let's say you have a folder /folder with a bunch of .sql files (the current directory will be used by default). If you run the following command
sql-organizer /folder
the tool will generate a target.sql file with the combined text from all the .sql files in the /folder (the search is recursive)
- Specifying file formats
sql-organizer /folder -e txt -e sql
This will find all the files with .txt and .sql formats in the /folder folder
- Specifying target path
sql-organizer /folder -t /my_target.sql
this will put the result into the my_target.sql file. The command will error if the file already exists by default, if you want to overwrite it put --overwrite parameter:
sql-oragnizer /folder -t /my_target.sql --overwrite
- Choose sorting strategies
sql-organizer /folder -so last_number
You can also chain the startegies, the priority is determined by the position, higher to lower priority Here are all the available strategies for now
| Stategy | Descrition |
|---|---|
| first_number | The ordering is based on the fist number found in the file name. 0 will be used if no number is found Example: 100_SCRIPT_2.sql -> 100 will be used for sorting |
| last_number | The ordering is based on the last number found in the file name. 0 will be used if no number is found Example: 100_SCRIPT_2.sql -> 2 will be used for sorting |
| folder | The name of the last folder will be used for soring. Sorting is done in an alphabetical order Example: my/folder/100_SCRIPT.sql -> folder will be used for soring |
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
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 sql_organizer-1.0.3.tar.gz.
File metadata
- Download URL: sql_organizer-1.0.3.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc14da361687ebefa3e69be2d6d941c45eaeee154ecdc1d4a6abc1979bce19c0
|
|
| MD5 |
76c80055e6225b4e7e24394f61cfef30
|
|
| BLAKE2b-256 |
5338245f14ac22a0510c50839a3ab24b28035a6eefcf8ef128aec6b8e0681aba
|
File details
Details for the file sql_organizer-1.0.3-py3-none-any.whl.
File metadata
- Download URL: sql_organizer-1.0.3-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2204055316c2ce5b2191f8cb67147b99acf816a7ebba345ead73f896972df01d
|
|
| MD5 |
3d0f3aed7df2c2788bd6b15eccb358e8
|
|
| BLAKE2b-256 |
8a4a6eb59c220172b1c8c34f436e7ca62b12e25c4a75e3581a1faca2f89b6516
|