AZQL is a tool for converting data files (CSV, JSON) to SQL DDL (Data Definition Language) scripts.
Project description
AZQL
AZQL is a tool for converting data files (CSV, TSV, JSON) to SQL DDL (Data Definition Language) scripts. It analyzes data files, detects data types, and generates appropriate SQL scripts for table creation.
Features
- Analyzes data from CSV and JSON files
- Automatically detects column data types
- Generates SQL DDL scripts for table creation
- Supports multiple SQL dialects (including TSQL)
- Validates data integrity before conversion
- Customizable SQL formatting options
- CLI and Python module interfaces
Installation
pip install azql
CLI Usage
AZQL can be used as a command-line tool to convert data files to SQL DDL scripts:
# Convert a single CSV file to SQL DDL
azql convert data.csv --dialect tsql --schema dbo
# Process all supported files in a directory
azql convert ./data_directory ./sql_scripts
# Customize the conversion with options
azql convert users.json --dialect tsql -s app -n 1000 --drop-table
CLI Options
# azql convert -h
usage: azql convert [-h] [-d DIALECT] [-s SCHEMA] [-t TABLE_NAME] [-n SAMPLE_SIZE] [--skip-validation] [--style STYLE] [--drop-table] input_file [output_dir]
positional arguments:
input_file Path to input data file / folder (csv, json)
output_dir Path to output SQL file
options:
-h, --help show this help message and exit
-d, --dialect SQL dialect (default: tsql, [mysql, postgresql])
-s, --schema SQL schema name, default `dbo`
-t, --table-name Name of the SQL table to create
-n, --sample-size Number of rows to sample for type detection
--skip-validation Skip data validation step.
--style Column style (default: input, [camel, pascal, snake])
--drop-table Include DROP TABLE statement, force drop
Python Module Usage
AZQL can also be imported and used as a Python module:
from pathlib import Path
import azql
# Convert a single CSV file to a SQL DDL script
ddl = azql.convert("data.csv", dialect="tsql", schema="dbo")
print(ddl)
# Process all supported files in a directory
azql.convert(Path("data_directory"), export=True)
# Customize the conversion with parameters
ddl = azql.convert(
"users.json",
sample_size=1000,
dialect="tsql",
schema="app",
drop_table=True,
style="snake",
)
Example Output
/*
ddl = azql.convert(
"users.json", dialect="tsql", schema="app", drop_table=True, style="snake"
)
*/
IF OBJECT_ID('app.users', 'U') IS NOT NULL
DROP TABLE [app].[users];
CREATE TABLE [app].[users] (
[id] INT NOT NULL
, [name] NVARCHAR(100) NOT NULL
, [email] NVARCHAR(255) NOT NULL
, [created_at] DATETIME NOT NULL
, [is_active] BIT NOT NULL
);
License
GNU General Public License v3.0
Developer Notice
This package was developed with the assistance of GitHub Copilot for documentation and testing purposes. However, every line of code has been manually reviewed and verified by the developers to ensure quality and security.
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 azql-0.1.1.tar.gz.
File metadata
- Download URL: azql-0.1.1.tar.gz
- Upload date:
- Size: 40.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f991a68cdf39abacf21f866c717f48afa74b6c31ce122490dc2ab21b48d3c506
|
|
| MD5 |
dec609d0f4e5f72c4dd6b18a3e786523
|
|
| BLAKE2b-256 |
4fc72049d193a908d5cbb16b65f045284cb613470c140c1f264f06a615666291
|
File details
Details for the file azql-0.1.1-py3-none-any.whl.
File metadata
- Download URL: azql-0.1.1-py3-none-any.whl
- Upload date:
- Size: 45.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b332b2f75927fa7211ec72bdf65175b35cb818ad48ee75e0c395e64b92df458d
|
|
| MD5 |
89dbcadf3504ba9e51990e02e447edca
|
|
| BLAKE2b-256 |
6b1611baa402e8f535e232d6ff871eed69f3d6e96fa2de5ae73751fcffb45cb2
|