Skip to main content

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

  1. The script reads an input CSV or Excel file.
  2. It normalizes the column names to ensure they are in the appropriate format for SQL (e.g., converting Name Id to Name_ID).
  3. The script automatically infers the column types (such as INTEGER, TEXT, etc.).
  4. It generates SQL INSERT INTO commands for each row in the file.
  5. 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.

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:

  1. Fork the Repository: Fork the repository to your GitHub account.

  2. Clone the Repository: Clone the repository to your local machine.

    git clone https://github.com/your_username/brokolisql.git
    
  3. Create a Branch: Create a new branch for your changes.

    git checkout -b my-new-feature
    
  4. Make Changes: Make the desired changes to the code. Be sure to follow the coding conventions and best practices.

  5. Tests: Add tests to ensure your changes don’t break existing functionality. Test the script to make sure it works as expected.

  6. 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
    
  7. 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

brokolisql-0.1.4.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brokolisql-0.1.4-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file brokolisql-0.1.4.tar.gz.

File metadata

  • Download URL: brokolisql-0.1.4.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for brokolisql-0.1.4.tar.gz
Algorithm Hash digest
SHA256 356f515b5689d625155063963ad91c100be93a9971a3f96c62995b0ca64d4838
MD5 7917225f1fd08b43c2c567eadc20e28c
BLAKE2b-256 2e642376fccfe55fae3aea38cf0c4c6c19aedaf8aa2266c9a5ccd6c888e0e237

See more details on using hashes here.

File details

Details for the file brokolisql-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: brokolisql-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for brokolisql-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 58fa42afebd7335b9df1c7571ca6233458bd51fdaad602287ca230376834672a
MD5 1969ed8ed97bb5708330387c1417a2f0
BLAKE2b-256 2fab6adefe0be416d9ef1e4c4fad274ec8da6dda35f3b3a3c37c945b0eb3ba91

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page