tobymao/sqlglot
View on GitHub ↗ ★ 9,747 Python
Python SQL Parser and Transpiler
36 mentions on Hacker News by 22 people: 9 stories, 27 comments · first 2021-03-19 · latest 2026-06-24
20082026
-
…tobymao/sqlglot: Python SQL Parser and Transpiler ; with tests and support for 30+ dialects: https://github.com/tobymao/sqlglot Ibis depends upon sqlglot: https://github.com/tobymao/sqlglot/network/dependents
comment by westurner · 2026-06-24 · in I rewrote PostHog's SQL parser, 70x faster, while barely looking at the code -
I'm curious because I have a similar use case for a querying frontend. Did you consider using https://github.com/tobymao/sqlglot ? If so, what was missing to justify writing your own parser?
comment by Lemaxoxo · 2026-02-06 · in A 2.5x faster Postgres parser with Claude Code -
…is a major driver for your considerations, then I would highly recommend looking at SQLGlot ( https://github.com/tobymao/sqlglot ), a transpiler that makes you (more) independent of query dialects. They already support 30 dialects (big…
comment by exagolo · 2025-12-17 · in Pg_ClickHouse: A Postgres extension for querying ClickHouse -
Agreed, and it's an amazingly well-maintained GitHub repo: https://github.com/tobymao/sqlglot Big kudos to Toby and the team.
comment by exagolo · 2025-10-29 · in Text-to-SQL is dead, long live text-to-SQL -
…query graphs; and there's sql-to-ibis: https://github.com/ibis-project/ibis/issues/9529 sqlglot: https://github.com/tobymao/sqlglot : > SQLGlot is a no-dependency SQL parser, transpiler, optimizer, and engine [written in Python] . It can…
comment by westurner · 2025-05-16 · in Show HN: SQL-tString a t-string SQL builder in Python -
Thanks for the suggestion! I am using https://github.com/tobymao/sqlglot , which magically supports most SQL dialects. And yes, support for DuckDB is also in future plans
comment by xarici_ishler · 2025-04-29 · in Ask HN: What are you working on? (April 2025) -
…engine. It's a lot simpler than you may think and it's a great exercise. If using python, sqlglot ( https://github.com/tobymao/sqlglot ) let's you skip all the parsing and it even does some simple optimizations. From the parsed query tree…
comment by ignoreusernames · 2025-04-27 · in Anatomy of a SQL Engine -
You can compose SQL with https://ibis-project.org/tutorials/ibis-for-sql-users , which is using https://github.com/tobymao/sqlglot to parse the SQL under the hood. As an alternative to parsing the SQL yourself, DuckDB's…
comment by ajfriend · 2024-11-28 · in Writing Composable SQL Using Knex and Pipelines -
Since you're using python, have you looked into sqlglot? I think it has some pretty-print options. https://github.com/tobymao/sqlglot
comment by chrisjc · 2024-11-15 · in What I wish someone told me about Postgres -
…sqlglot into being a formatter but it's designed for forgiving dialect conversion, not formatting https://github.com/tobymao/sqlglot
comment by NortySpock · 2024-09-26 · in SQL Tips and Tricks -
…to automate 80% of the translation (assuming it's just a select statement). You might take a look. https://github.com/tobymao/sqlglot
comment by NortySpock · 2024-06-19 · in Open Source Python ETL -
…like COALESCE(5, FALSE) and emulation of system catalogs (pg_catalog, information_schema). [1] https://github.com/tobymao/sqlglot
comment by aerzen · 2024-04-26 · in The Future of MySQL is PostgreSQL: an extension for the MySQL wire protocol -
Recommend checking out https://github.com/tobymao/sqlglot if you are interested in this capability for other SQL dialects Tools like this are helpful for: - Rendering SQL in a consistent way, eg for snapshot testing - Testing SQL business…
comment by r1b · 2024-03-18 · in Transpile Any SQL to PostgreSQL Dialect -
SQLGlot brands itself as an sql optimizer also: https://github.com/tobymao/sqlglot?tab=readme-ov-file#sql-op... but I haven't tried that aspect of it personally
comment by hantusk · 2024-03-18 · in Building a streaming SQL engine with Arrow and DataFusion -
▲ 3
SQLGlot: No-dependency SQL parser, transpiler, optimizer for 21 SQL dialectsstory by thunderbong · 2024-03-18 · 0 comments
-
▲ 2
SQLglot: Python SQL Parser and Transpilerstory by tosh · 2024-03-13 · 0 comments
-
▲ 3
A Primer on SQLGlot's Abstract Syntax Treestory by captaintobs · 2023-12-19 · 0 comments
-
Cool! Is this built with sqlglot[1] on the back end? [1] https://github.com/tobymao/sqlglot
comment by colinmilhaupt · 2023-12-16 · in Show HN: SQL Polyglot -
▲ 7
SQLGlot – Python no-dependency SQL parser, transpiler, optimizer, and enginestory by ekiauhce · 2023-11-17 · 0 comments
-
…using frameworks/libraries such as Substrait and SQLGlot to accomplish this. https://substrait.io/ https://github.com/tobymao/sqlglot
comment by chrisjc · 2023-09-18 · in Relational is more than SQL -
…#. ibis-project/ibis-substrait: https://github.com/ibis-project/ibis-substrait #. tobymao/sqlglot: https://github.com/tobymao/sqlglot : > SQLGlot is a no-dependency SQL parser, transpiler, optimizer, and engine. It can be used to format…
comment by westurner · 2023-08-09 · in SQLedge: Replicate Postgres to SQLite on the Edge -
Links: SQLGlot - https://news.ycombinator.com/item?id=31981568 , https://github.com/tobymao/sqlglot Presto - https://github.com/prestodb/presto
comment by deemarklit · 2023-07-14 · in Ask HN: recommending a SQL transpiler -
▲ 3
Ask HN: recommending a SQL transpilerstory by deemarklit · 2023-07-14 · 1 comment
-
sqlglot might be what you are looking for. https://github.com/tobymao/sqlglot
comment by snthpy · 2023-04-15 · in SQL:2023 is finished: Here is what's new -
▲ 112
Writing a Python SQL engine from scratchstory by captaintobs · 2023-01-03 · 15 comments
-
recursion! https://github.com/tobymao/sqlglot/tree/main/sqlglot/optimiz...
comment by captaintobs · 2022-12-30 · in I wrote a SQL engine in Python -
…vary greatly. Here's an example of how we use SQLGlot to output raw Python code directly from SQL. https://github.com/tobymao/sqlglot/blob/main/sqlglot/executo...
comment by captaintobs · 2022-07-29 · in Semantic Diff for SQL -
https://github.com/tobymao/sqlglot
comment by nerpderp82 · 2022-07-29 · in Semantic Diff for SQL -
▲ 228
Semantic Diff for SQLstory by s0ck_r4w · 2022-07-29 · 31 comments
-
…identical to Any so I always default to Any. You can see what it took to add this in this commit. https://github.com/tobymao/sqlglot/commit/ab49a3a2964bdff3a3...
comment by captaintobs · 2022-07-05 · in SQLGlot: SQL parser, transpiler, optimizer – translate to Presto, Spark, Hive -
…fully supported yet but it's only a couple lines to add support since I already support EXISTS. https://github.com/tobymao/sqlglot/blob/main/tests/fixtures/... https://github.com/tobymao/sqlglot/blob/main/tests/fixtures/...
comment by captaintobs · 2022-07-05 · in SQLGlot: SQL parser, transpiler, optimizer – translate to Presto, Spark, Hive -
You should try it out and see. Here are the test cases https://github.com/tobymao/sqlglot/blob/main/tests/fixtures/... I can even parse and optimize TPC-H https://github.com/tobymao/sqlglot/blob/main/tests/fixtures/... . SQLGlot's parser…
comment by captaintobs · 2022-07-05 · in SQLGlot: SQL parser, transpiler, optimizer – translate to Presto, Spark, Hive -
…10k lines. The SQL is a monstrous language. Is there any trick that keeps the code simple? [1] https://github.com/tobymao/sqlglot/blob/main/sqlglot/parser.... [2] https://github.com/duckdb/duckdb/blob/master/third_party/lib... [3]…
comment by flakiness · 2022-07-05 · in SQLGlot: SQL parser, transpiler, optimizer – translate to Presto, Spark, Hive -
…here, feel free to ask me any questions! Something that I'm working on is a pure python SQL engine https://github.com/tobymao/sqlglot/blob/main/sqlglot/executo... . It does the whole shebang, parsing, optimizations, logical planning,…
comment by captaintobs · 2022-07-05 · in SQLGlot: SQL parser, transpiler, optimizer – translate to Presto, Spark, Hive -
▲ 120
SQLGlot: SQL parser, transpiler, optimizer – translate to Presto, Spark, Hivestory by blopeur · 2022-07-04 · 40 comments
-
▲ 5
Show HN: SQLGlot – Customizable Python SQL Transpilerstory by captaintobs · 2021-03-19 · 2 comments