GitHub - gpicode/db2exa-sqlglot: Cross-dialect SQL transpiler

sqlglot-exasol

๐Ÿš€ Transpile any SQL dialect to Exasol SQL using a custom sqlglot dialect.

This project extends sqlglot with a custom dialect for Exasol, enabling SQL translation from dialect to Exasol syntax.

โš ๏ธ This fork includes an unpublished Exasol dialect. You must install this fork locally to use the transpiler.


โœจ Features

  • Convert sql dialect to Exasol-compatible syntax
  • Uses the sqlglot AST to handle dialect transformations
  • Easily transpile .sql files from one dialect to another

๐Ÿ”ง Installation

Clone this repo and install your forked version of sqlglot locally:

git clone https://github.com/gpicode/sqlglot
cd sqlglot
git checkout staging
pip install -e .

NOTE: Ensure you check out the staging branch to use this fork.

๐Ÿ“„ Usage

Transpile a SQL file from Sqlite to Exasol Example usage from the command line (create a script like transpile.py) or use the sample transpile.py file:

import sqlglot

with open("input.sql", "r") as f:
    sql = f.read()

# Use your custom dialect
transpiled_sql = sqlglot.transpile(sql, read="databricks", write="exasol")[0]

with open("output.sql", "w") as f:
    f.write(transpiled_sql)

๐Ÿงช Example

Using the sample transpile.py file to transpile a file from Sqlite to Exasol, run:

python transpile.py input.sql output.sql