Metadata-Version: 2.4
Name: sql-organizer
Version: 1.0.3
Summary: 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-URL: Repository, https://github.com/TheSuperShell/sql-organizer
Author-email: Steven Rudenko <steven.gucum@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Steven Rudenko
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: os,sql
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: pydantic>=2.11.7
Requires-Dist: rich>=14.0.0
Requires-Dist: typer>=0.16.0
Description-Content-Type: text/markdown

```
  ____   ___  _        ___                        _              
 / ___| / _ \| |      / _ \ _ __ __ _  __ _ _ __ (_)_______ _ __ 
 \___ \| | | | |     | | | | '__/ _` |/ _` | '_ \| |_  / _ \ '__|
  ___) | |_| | |___  | |_| | | | (_| | (_| | | | | |/ /  __/ |   
 |____/ \__\_\_____|  \___/|_|  \__, |\__,_|_| |_|_/___\___|_|   
                                |___/                            

```
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

```bash
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

```bash
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

```bash
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

```bash
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:

```bash
sql-oragnizer /folder -t /my_target.sql --overwrite
```

- Choose sorting strategies

```bash
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<br>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<br>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<br>Example: `my/folder/100_SCRIPT.sql` -> folder will be used for soring |

