Convert CSV and Excel files into SQL INSERT commands.
Project description
Here's the README in English for the BrokoliSQL project:
BrokoliSQL
BrokoliSQL is a Python script designed to facilitate the conversion of CSV and Excel files into SQL insertion commands. It reads a CSV or Excel file and generates SQL INSERT INTO commands based on the columns in the file. The generated commands are then written to a specified output file.
How It Works
BrokoliSQL works in a simple and intuitive way. It allows you to insert data from CSV or Excel files directly into a SQL database, without the need to manually perform the insertion.
Execution Flow
- The script reads an input CSV or Excel file.
- It normalizes the column names to ensure they are in the appropriate format for SQL (e.g., converting
Name IdtoName_ID). - The script automatically infers the column types (such as
INTEGER,TEXT, etc.). - It generates SQL
INSERT INTOcommands for each row in the file. - The SQL commands are written to an output file, ready to be executed in a database.
How to Use
To use BrokoliSQL, you can run the script directly from the command line. Here’s the basic syntax:
python cli.py --input <path_to_input_file> --output <path_to_output_file> --table <table_name>
Arguments:
--input: Path to the input CSV or Excel file.--output: Path to the output file where SQL commands will be generated.--table: Name of the SQL table where the data will be inserted.
Example Usage
python cli.py --input data.csv --output commands.sql --table products
This will generate SQL commands to insert the data from data.csv into the products table, and save the commands in the commands.sql file.
Perfeito! Aqui está uma sugestão de seção para adicionares ao teu README.md, explicando como instalar e usar o BrokoliSQL após a publicação no PyPI:
You can install BrokoliSQL directly from PyPI using pip:
pip install brokolisql
Usage
Once installed, you can use the brokolisql command in your terminal:
brokolisql --input path/to/your/file.csv --output output.sql --table your_table_name
Example:
brokolisql --input data/users.xlsx --output sql/users.sql --table users
Prerequisites
Make sure you have Python 3 installed on your system. You can check the Python version by running:
python --version
Install the necessary dependencies by running:
pip install -r requirements.txt
Project Structure
The project is organized as follows:
BrokoliSQL/
│
├── cli.py # Main command line script
├── requirements.txt # Dependencies file
├── utils/ # Utility functions (e.g., file loading)
│ └── file_loader.py # Loads CSV/Excel files and normalizes data
├── services/ # Service functions (e.g., SQL generation)
│ ├── sql_generator.py # Generates SQL commands
│ └── normalizer.py # Normalizes column names
├── output/ # Output functions
│ └── output_writer.py # Writes SQL commands to a file
├── .gitignore # Files and folders to be ignored by Git
├── banner.txt # Text-based banner displayed on execution
└── README.md # This file
Contributing to the Project
If you want to contribute to BrokoliSQL, follow these steps:
-
Fork the Repository: Fork the repository to your GitHub account.
-
Clone the Repository: Clone the repository to your local machine.
git clone https://github.com/your_username/brokolisql.git
-
Create a Branch: Create a new branch for your changes.
git checkout -b my-new-feature
-
Make Changes: Make the desired changes to the code. Be sure to follow the coding conventions and best practices.
-
Tests: Add tests to ensure your changes don’t break existing functionality. Test the script to make sure it works as expected.
-
Commit and Push: After making your changes, commit and push them to the remote repository.
git add . git commit -m "feat(postgres): Add support to postgres" git push origin my-new-feature
-
Create a Pull Request: Open a pull request explaining your changes and why they are necessary.
Code Standards
- Code Style: Use the PEP 8 coding style for Python.
- Function and Variable Names: Use clear and descriptive names.
- Tests: Add unit tests wherever possible to validate the features.
License
This project is licensed under the GPL-3.0. Please refer to the LICENSE file for more details.
BrokoliSQL simplifies inserting data from CSV and Excel files into SQL databases, and we welcome contributions! If you find a bug or have an improvement suggestion, feel free to open an issue or 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 brokolisql-0.1.5.tar.gz.
File metadata
- Download URL: brokolisql-0.1.5.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1da9ff4ccc70129c3827c50407a7995d914dd9a9045295f500166ccbb56391eb
|
|
| MD5 |
0a6b929cef53cc897153a82ec61ea0ce
|
|
| BLAKE2b-256 |
ee65711fb23dc51d7c108be68833b539e625ff548f151d44e1cdc2d87eea7e52
|
File details
Details for the file brokolisql-0.1.5-py3-none-any.whl.
File metadata
- Download URL: brokolisql-0.1.5-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12304db2cc2506418337ff0b656fdd2df278dbf2b59a61dfe5acc4a8e826f494
|
|
| MD5 |
cd18276195a3947e8d8550b9a8bc7889
|
|
| BLAKE2b-256 |
2fb77268b4130ad4a06536de3a7f535be704bed4c91a4cee39809b1a24ac6793
|