
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
BrokoliSQL is a Python-based command-line tool designed to facilitate the conversion of structured data files—such as CSV, Excel, JSON, and XML—into SQL INSERT statements. It solves common problems faced during data import, transformation, and database seeding by offering a flexible, extensible, and easy-to-use interface.
Universal Data-to-SQL Converter
BrokoliSQL is a Python-based command-line tool designed to facilitate the conversion of structured data files—such as CSV, Excel, JSON, and XML—into SQL INSERT
statements. It solves common problems faced during data import, transformation, and database seeding by offering a flexible, extensible, and easy-to-use interface.
--dialect
option.CREATE TABLE
statement based on input data.INSERT
.The execution process is straightforward:
Name Id
→ Name_ID
) for SQL compatibility.INTEGER
, TEXT
, etc.).INSERT INTO
statements (and optionally CREATE TABLE
).Install from PyPI:
pip install brokolisql
Make sure you have Python 3 installed:
python --version
If you're working with the source code, install dependencies with:
pip install -r requirements.txt
brokolisql --input data.csv --output output.sql --table users
Use a specific SQL dialect:
brokolisql --input data.csv --output output.sql --table users --dialect mysql
Generate a CREATE TABLE
statement:
brokolisql --input data.csv --output output.sql --table users --create-table
Use batch inserts for better performance:
brokolisql --input data.csv --output output.sql --table users --batch-size 100
Specify input format explicitly:
brokolisql --input data.xml --output output.sql --table users --format xml
Apply Python-based transformations:
brokolisql --input data.csv --output output.sql --table users --transform transforms.json
transforms.json
:{
"transformations": [
{
"type": "rename_columns",
"mapping": {
"FIRST_NAME": "GIVEN_NAME",
"LAST_NAME": "SURNAME",
"PHONE_1": "PRIMARY_PHONE",
"PHONE_2": "SECONDARY_PHONE"
}
},
{
"type": "add_column",
"name": "FULL_NAME",
"expression": "FIRST_NAME + ' ' + LAST_NAME"
},
{
"type": "add_column",
"name": "SUBSCRIPTION_AGE_DAYS",
"expression": "(pd.Timestamp('today') - pd.to_datetime(df['SUBSCRIPTION_DATE'])).dt.days"
},
{
"type": "filter_rows",
"condition": "COUNTRY in ['USA', 'Canada', 'Norway', 'UK', 'Germany']"
},
{
"type": "apply_function",
"column": "EMAIL",
"function": "lower"
},
{
"type": "apply_function",
"column": "WEBSITE",
"function": "lower"
},
{
"type": "replace_values",
"column": "COUNTRY",
"mapping": {
"USA": "United States",
"UK": "United Kingdom"
}
},
{
"type": "drop_columns",
"columns": ["INDEX"]
},
{
"type": "add_column",
"name": "EMAIL_DOMAIN",
"expression": "EMAIL.str.split('@').str[1]"
},
{
"type": "sort",
"columns": ["COUNTRY", "CITY", "GIVEN_NAME"],
"ascending": true
}
]
}
This enables flexible pre-processing logic during data conversion, such as cleaning strings, formatting dates, or extracting information.
If running directly from source:
PYTHONPATH=. python brokolisql/cli.py --input <path_to_input_file> --output <path_to_output_file> --table <table_name>
Example:
PYTHONPATH=. python brokolisql/cli.py --input data.csv --output commands.sql --table products
brokolisql/
├── assets
│ └── banner.txt
├── cli.py
├── dialects
│ ├── base.py
│ ├── generic.py
│ ├── __init__.py
│ ├── mysql.py
│ ├── oracle.py
│ ├── postgres.py
│ ├── sqlite.py
│ └── sqlserver.py
├── examples
│ ├── customers-10000.csv
│ ├── customers-100.csv
│ ├── output.sql
│ └── transforms.json
├── exceptions
│ ├── base.py
│ └── __init__.py
├── output
│ └── output_writer.py
├── services
│ ├── normalizer.py
│ ├── sql_generator.py
│ └── type_inference.py
├── setup.py
├── transformers
│ ├── __init__.py
│ └── transform_engine.py
└── utils
└── file_loader.py
We welcome contributions to improve BrokoliSQL. To contribute:
Fork the repository.
Clone it to your machine.
Create a feature branch:
git checkout -b my-feature
Make your changes following PEP 8 standards.
Add or update tests.
Commit and push your changes:
git add .
git commit -m "feat(minor): add X support"
git push origin my-feature
Open a pull request describing your changes and why they are useful.
BrokoliSQL is licensed under the GNU GPL-3.0. See the LICENSE file for more information.
BrokoliSQL streamlines the process of converting structured data into clean, executable SQL. Whether you're migrating legacy data, seeding databases for development, or automating ingestion workflows, BrokoliSQL is a flexible and reliable tool that adapts to your needs. With support for Python-powered transformations and multiple database dialects, it brings power and simplicity to your data operations.
If you encounter any bugs, have suggestions, or would like to contribute, feel free to open an issue or submit a pull request.
FAQs
BrokoliSQL is a Python-based command-line tool designed to facilitate the conversion of structured data files—such as CSV, Excel, JSON, and XML—into SQL INSERT statements. It solves common problems faced during data import, transformation, and database seeding by offering a flexible, extensible, and easy-to-use interface.
We found that brokolisql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.