transqlate

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: PostgreSQL Imports: 1 Imported by: 0

README

transqlate: Transpile any SQL to PostgreSQL Dialect

Go Reference Go Report Card

Project is early in its development

Features

  • translate Oraclisms to PostgreSQL dialect
  • handle identifier case
  • preserve whitespaces, case and comments
  • top-notch error reporting
  • parses script or any expression
  • simple CLI with syntax highlighting or Go idiomatic API
  • prettify following Simon Holywell guide
CLI Example

Use transqlate tool to translate any Oracle SQL snippet to PostgreSQL dialect.

$ transqlate
Type SQL snippet and terminate with ^D
SELECT SYSDATE FROM DUAL; -- my comment
^D
SELECT CURRENT_TIMESTAMP; -- my comment
$
Go Example

This simplest entrypoint is the oracle package.

package main

import (
	"fmt"

	"gitlab.com/dalibo/transqlate/oracle"
)

func main() {
	pgsql, err := oracle.Translate("file.sql", `SELECT SYSDATE FROM DUAL;`)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println(pgsql)
	// Output: SELECT LOCALTIMESTAMP;
}

Installation

Use packages or binary available on Releases page.

Roadmap

  • more SQL syntax
  • more rewriting rules
  • more source dialects : mysql, mssql, sybase, etc.

Feel free to share your cases by opening a GitLab issue !

The main target dialect is PostgreSQL. Feel free to reuse transqlate to target another dialect.

Support

If you found a bug or have a feature request, please file a GitLab issue.

Authors

Transqlate is a Dalibo Labs project available under PostgreSQL license.

References

  • Ora2Pg - the venerable open source reference for migration to PostgreSQL.
  • sqlparser-rs - a TDOP SQL parser for Rust
  • sqlglot - a SQL frontend for Python app
  • pg_query_go - use Postgres parser in Go

Documentation

Overview

transqlate converts SQL from a dialect to PostgreSQL.

Usage: transqlate [flags] [file]

See --help for details.

See https://pkg.go.dev/gitlab.com/dalibo/transqlate for API documentation.

Directories

Path Synopsis
ast
Package ast represents SQL code hierarchy.
Package ast represents SQL code hierarchy.
joinmark
Package joinmark converts Oracle JOIN mark
Package joinmark converts Oracle JOIN mark
parser
Package parser contains the universal TDOP parser for SQL snippet.
Package parser contains the universal TDOP parser for SQL snippet.
render
Package render presents AST, traces and SQL
Package render presents AST, traces and SQL
rules
Package rules holds common rewrite rules
Package rules holds common rewrite rules
startwith
Package startwith converts Oracle recursive query
Package startwith converts Oracle recursive query
Package lexer tokenizes SQL.
Package lexer tokenizes SQL.
Package oracle transpiles from Oracle to PostgreSQL.
Package oracle transpiles from Oracle to PostgreSQL.
Package rewrite edits an AST.
Package rewrite edits an AST.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL