Skip to main content

sqlflip

Paste a SQL query and sqlflip will:

  1. Detect which dialect it is written in - PostgreSQL, MySQL, SQL Server (T-SQL) or standard SQL.
  2. Convert it to the other dialects (identifier quoting, TOP / LIMIT / OFFSET .. FETCH, GETDATE() / NOW(), ISNULL / IFNULL / COALESCE, LEN / LENGTH, common data types).
  3. Display all versions in a small window (Tkinter, no extra dependencies).

T-SQL is the language of SQL Server, so tsql and sqlserver mean the same thing.

Install

pip install sqlflip

(On Linux you may also need sudo apt install python3-tk for the window.)

Use in Python

from sqlflip import detect_dialect, convert, convert_all, display

q = "SELECT TOP 10 [name], ISNULL([age], 0) FROM [users] ORDER BY [name]"

print(detect_dialect(q))            # SQL Server (T-SQL) (confidence: high)
print(convert(q, "postgresql").sql) # SELECT "name", COALESCE("age", 0) FROM "users" ORDER BY "name" LIMIT 10
print(convert(q, "mysql").sql)      # SELECT `name`, IFNULL(`age`, 0) FROM `users` ORDER BY `name` LIMIT 10

for dialect, result in convert_all(q).items():
    print(dialect, "->", result.sql, result.notes)

display(q)                          # opens the window

Command line

sqlflip "SELECT TOP 5 * FROM users"
sqlflip "SELECT * FROM users LIMIT 5, 10" --to sqlserver
sqlflip --gui

Limitations

This is a lightweight, rule-based tool - not a full SQL parser. Always review the output. Constructs it cannot safely translate (e.g. :: casts, || / + string concatenation, auto-increment columns, GROUP_CONCAT / STRING_AGG, date functions, variables) are left as-is and reported in result.notes. Detection is heuristic: a query such as SELECT * FROM t LIMIT 5 is valid in both PostgreSQL and MySQL, so it is reported as ambiguous.

Publish to PyPI

pip install build twine
python -m build
twine upload dist/*        # username: __token__   password: <your API token>

Metadata

Release files for sqlflip 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlflip 0.1.1
File Size Uploaded Provenance Actions
sqlflip-0.1.1.tar.gz 12.6 kB Without provenance Details for sqlflip-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlflip 0.1.1
File Interpreter ABI Platform Actions
sqlflip-0.1.1-py3-none-any.whl Python 3 none any Details for sqlflip-0.1.1-py3-none-any.whl

Total release size: 25.4 kB

Release files / sqlflip-0.1.1.tar.gz

Download URL sqlflip-0.1.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6450adc4d0bcb62e7e08820891f370f00ca91b30e7c3b92e92048d137d25e215
BLAKE2b-256 checksum
How to use checksums
e2fcb99fe35208d9268d40a85b04515b5d2b0aad61a39031ed8b511daf5996ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / sqlflip-0.1.1-py3-none-any.whl

Download URL sqlflip-0.1.1-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bed1fbb06567b9520fe01647e43c86925dc606d9386ca534f8b60baaafad92be
BLAKE2b-256 checksum
How to use checksums
bfb0af3543d9cfea496660f87fbd71bebaa15f6852e3571e41b56c063624cf85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for sqlflip 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page