-
Notifications
You must be signed in to change notification settings - Fork 4
Description
The Vision
We are building the "Babel for SQL."
Developers shouldn't be trapped in vendor lock-in. You should be able to write a query once in a standard syntax, and have it run seamlessly on PostgreSQL, MySQL, SQLite, Snowflake, or Oracle without changing a single line of code.
xsql will act as the intelligent translation layer between your application and your database.
The Problem: The Database "Tower of Babel"
We have all been there. You build an application using PostgreSQL. Six months later, you need to migrate to Snowflake for analytics, or support a client who insists on Oracle.
Suddenly, your codebase is broken.
- Postgres uses
gen_random_uuid(), MySQL needsUUID(). - String concatenation uses
||here andCONCAT()there. - JSON extraction syntax varies wildly.
We spend too much time rewriting queries for different backends. ORMs try to solve this, but they often hide the power of raw SQL or generate inefficient queries.
The Solution: Intelligent Transpilation
xsql will accept a standardized SQL dialect (aiming for ISO/Postgres standard) and recompile it into the specific dialect required by the active connection.
Example 1: The Dreaded Upsert
Input (Standard xsql):
INSERT INTO users (id, name, email)
VALUES (1, 'Dawaman', 'dawa@example.com')
ON CONFLICT (id) DO UPDATE SET email = EXCLUDED.email;
Output (If xsql is connected to MySQL):
-- xsql automatically rewrites to:
INSERT INTO users (id, name, email)
VALUES (1, 'Dawaman', 'dawa@example.com')
ON DUPLICATE KEY UPDATE email = VALUES(email);
Example 2: JSON Handling
Input (Standard xsql):
SELECT metadata ->> 'color' as color FROM items;
Output (If xsql is connected to SQLite):
-- xsql automatically rewrites to:
SELECT json_extract(metadata, '$.color') as color FROM items;
🛠 Architecture & Roadmap
To achieve this, we need to build a robust pipeline:
- Lexer/Parser: Convert raw SQL strings into a comprehensive Abstract Syntax Tree (AST).
- Transformer: Manipulate the AST (e.g., swapping function nodes, rewriting logic).
- Dialect Generators: Walk the AST to generate valid SQL strings for specific targets (PG, MySQL, SQLite, etc.).
🤝 How to Contribute
This is a ground-floor opportunity. We are looking for contributors to help with:
- Designing the initial AST structure.
- Writing the Lexer (Go/Rust/Python TBD).
- Defining the "Standard xsql" spec.
Let's build the last SQL tool anyone ever needs.
<img width="1408" height="768" alt="Image" src="https://github.com/user-attachments/assets/299d92aa-3a0c-408a-86ad-1bcb2729a8f7" />