Skip to main content

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] DATETIME2 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.

Metadata

Release files for azql 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for azql 0.1.3
File Size Uploaded
azql-0.1.3.tar.gz 41.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for azql 0.1.3
File Interpreter ABI Platform
azql-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 87.3 kB

Release files / azql-0.1.3.tar.gz

Download URL azql-0.1.3.tar.gz
Size 41.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d242f27d76c4626617f687f15df3ad0bd25a3724f35c27bdf7a6a48aa72593ad
BLAKE2b-256 checksum
How to use checksums
6cd6017f404a3d6487664e1f1b7ec40e3c1f19d3a9197b686876acc3f22337f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Release files / azql-0.1.3-py3-none-any.whl

Download URL azql-0.1.3-py3-none-any.whl
Size 45.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e5cd81d2502ef1a57aacea013db3e2437882d2740aabfa2f95b696ac7ed84e1
BLAKE2b-256 checksum
How to use checksums
8803b396fc7dc0228cdd648b8117e8a12dbf500c934822ed044849697e4be18d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.2

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page