Skip to content

Latest commit

 

History

History
49 lines (33 loc) · 2.19 KB

getting-started.md

File metadata and controls

49 lines (33 loc) · 2.19 KB

Getting started

sqlglot-go is a Go port of sqlglot. Use it as a command line tool or import its parser, generator, and migration packages into a Go application.

Install the CLI

Install the Go toolchain version declared in go.mod, then run:

go install github.com/flanksource/sqlglot-go/cmd/sqlglot@latest
sqlglot dialects
sqlglot parse --dialect tsql 'SELECT TOP 2 name FROM users'

Ensure Go's GOBIN (or GOPATH/bin when GOBIN is unset) is on your PATH. Prebuilt archives for Linux, macOS, and Windows are available on the releases page.

Build a checkout

git clone https://github.com/flanksource/sqlglot-go.git
cd sqlglot-go
make install
sqlglot parse 'SELECT id FROM users'

make install installs the current checkout into Go's binary directory. Make targets assume a POSIX shell; Windows contributors can use WSL or Git Bash.

Install the browser app from a checkout

The browser application needs a build that includes its web assets. make install builds them (Node.js and pnpm required) and embeds them, so from the checkout:

make install
sqlglot ui

A plain go install ./cmd/sqlglot leaves the web assets out, and its sqlglot ui refuses to start.

Open the address printed by sqlglot ui. This installs the browser-enabled command on your normal Go binary path; subsequent sessions start with just sqlglot ui.

Pick a workflow

Parsing proves that the parser understands the statement. It does not establish read-only policy, validate schema names, or prove that a database will execute it.