-
Notifications
You must be signed in to change notification settings - Fork 3
Description
We need a converter that will take a .sql file in one syntax (e.g. Postgres syntax) and convert it to another (e.g. MySQL) syntax.
This will make it possible to make a web app primarily developing against one database (e.g. Postgres or SQLite) then add support for another database with minimal work by combining multi-db-driver's existing features with a full schema file converter to fully automate the process of "write once, support many" as much as possible.
Initial hypothesis: This can probably can be done by abstracting a bunch of dedicated tools that are designed to convert things in one direction. More research needed on what underlying tools are available and/or are best to use.
Initial research:
Some tools that looked interesting at first:
- It looks like you can use https://github.com/tobymao/sqlglot as a command line tool to convert anything to anything else, and it looks explicitly designed to be used for this purpose.
- This online server looks cool https://sql-tools.org/ but we can't find a downloadable version.
- The downloadable version of this one https://www.jooq.org/translate/ seems like a hassle, like they want you to pay for it or jump through obnoxious hoops to get the free version https://www.jooq.org/download/
- https://docs.myaltimate.com/develop/translateSQL/ seems like a dev tool for VS Code but maybe there is a way to get a generic CLI version of it.
We looked into this and none of those tools appeared good at translating schema dumps from one SQL dialect to another. Translating individual queries looks mostly feasible, but schema dumps are much more difficult to translate.
2025-12-19 update:
This tool shows some promise, worth looking into: https://github.com/Dawaman43/xsql