Skip to main content

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

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

azql-0.1.3.tar.gz (41.7 kB view details)

Uploaded Source

Built Distribution

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

azql-0.1.3-py3-none-any.whl (45.7 kB view details)

Uploaded Python 3

File details

Details for the file azql-0.1.3.tar.gz.

File metadata

  • Download URL: azql-0.1.3.tar.gz
  • Upload date:
  • Size: 41.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.2

File hashes

Hashes for azql-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d242f27d76c4626617f687f15df3ad0bd25a3724f35c27bdf7a6a48aa72593ad
MD5 c1c110bce61f96d07307ba371567f1da
BLAKE2b-256 6cd6017f404a3d6487664e1f1b7ec40e3c1f19d3a9197b686876acc3f22337f6

See more details on using hashes here.

File details

Details for the file azql-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: azql-0.1.3-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

Hashes for azql-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6e5cd81d2502ef1a57aacea013db3e2437882d2740aabfa2f95b696ac7ed84e1
MD5 4681c89bae6ff9653e532ce4e7357852
BLAKE2b-256 8803b396fc7dc0228cdd648b8117e8a12dbf500c934822ed044849697e4be18d

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