Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ resolver = "2"
members = [
"crates/polyglot-sql",
"crates/polyglot-sql-wasm",
"crates/polyglot-sql-python",
"crates/polyglot-sql-tags",
]
exclude = [
"examples/rust",
Expand Down
16 changes: 16 additions & 0 deletions crates/polyglot-sql-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "polyglot-sql-python"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "Python bindings for polyglot-sql — a high-performance SQL transpiler"

[lib]
name = "_polyglot_core"
crate-type = ["cdylib"]

[dependencies]
polyglot-sql = { path = "../polyglot-sql" }
polyglot-sql-tags = { path = "../polyglot-sql-tags" }
pyo3 = { version = "0.23", features = ["extension-module"] }
serde_json = "1.0"
28 changes: 28 additions & 0 deletions crates/polyglot-sql-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# polyglot-sql (Python)

High-performance SQL transpiler with a **sqlglot-compatible** Python API, powered by a Rust core.

## Installation

```bash
pip install polyglot-sql
```

## Usage

```python
import polyglot

# Transpile SQL between dialects
result = polyglot.transpile(
"SELECT EPOCH_MS(1618088028295)",
read="duckdb",
write="hive"
)

# Parse SQL into an AST
expr = polyglot.parse_one("SELECT id, name FROM users", read="postgres")

# Generate SQL for a different dialect
print(expr.sql(dialect="mysql"))
```
30 changes: 30 additions & 0 deletions crates/polyglot-sql-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[build-system]
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[project]
name = "polyglot-sql"
version = "0.1.4"
description = "High-performance SQL transpiler with sqlglot-compatible Python API"
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.8"
keywords = ["sql", "transpile", "dialect", "parser"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Rust",
"Topic :: Database",
"Topic :: Software Development :: Compilers",
]

[project.optional-dependencies]
dev = ["pytest>=7.0"]

[tool.maturin]
features = ["pyo3/extension-module"]
module-name = "polyglot._polyglot_core"
python-source = "python"
Loading