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

azql-0.1.2.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.2-py3-none-any.whl (45.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: azql-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 ee98cb4d59bd89a021ab959c61aba47e7981e586ad16b6fa3dfae3bc8d1da706
MD5 30889df3b2c690946d041a55727ea093
BLAKE2b-256 38573c9160ede14076f287ca867a9d8747577071f5115169e98d872e773f0b72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: azql-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f2213dabad3aab259e8a0434573f305ed470c17f15bcd06f99bb2a951b743c3
MD5 8a4ddc2d524b129b4c98600f85e8f297
BLAKE2b-256 7cf1d57d1e0fd77453364ed10d0046f0a82fef5b4de1a7c7c680336b5e849637

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