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 sqlflipview 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 sqlflipview 0.1.1
File Size Uploaded Provenance Actions
sqlflipview-0.1.1.tar.gz 12.7 kB Without provenance Details for sqlflipview-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 25.4 kB

Release files / sqlflipview-0.1.1.tar.gz

Download URL sqlflipview-0.1.1.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7f854b5de15f7ae41fbe24b3113fb780ca1f77c51038123a431f94d7c6726093
BLAKE2b-256 checksum
How to use checksums
dea335f63fdbe17bf09bc898b2619b6cfad1d9a7de199f24bffef58532510ed0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

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

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

Security for sqlflipview 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