GoSQLX is a read-only SQL analysis server offering 7 tools for working with SQL queries across multiple dialects (generic, mysql, postgresql, sqlite, sqlserver, oracle, snowflake):
analyze_sql: Run all 6 analysis tools concurrently and return a single composite report.validate_sql: Check SQL syntax correctness with optional dialect-specific validation.parse_sql: Parse SQL and return an AST summary including statement count and types.extract_metadata: Extract referenced tables, columns, and functions from SQL.format_sql: Reformat SQL with configurable indent size, trailing semicolon, and keyword casing.lint_sql: Apply up to 10 style rules (L001โL010) to catch style and quality issues.security_scan: Detect SQL injection patterns such as tautologies, UNION attacks, stacked queries, and comment bypasses.
Enables parsing, formatting, validation, and analysis of MySQL SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
Enables parsing, formatting, validation, and analysis of PostgreSQL SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
Enables parsing, formatting, validation, and analysis of Snowflake SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
Enables parsing, formatting, validation, and analysis of SQLite SQL queries, providing tools for linting, metadata extraction, and identifying potential security vulnerabilities.
GoSQLX
Parse SQL at the speed of Go
๐ Go Version
๐ Release
๐ License
๐ PRs Welcome
๐ Website
๐ VS Code
๐ MCP
๐ Glama MCP Server
๐ Lint Action
๐ Tests
๐ Go Report
๐ GoDoc
๐ Stars
๐ OpenSSF Scorecard
๐ Try the Playground ยท ๐ Read the Docs ยท ๐ Get Started ยท ๐ Benchmarks
1.38M+ ops/sec | <1ฮผs latency | 85% SQL-99 | 8 dialects | 0 race conditions |
What is GoSQLX?
GoSQLX is a production-ready SQL parsing SDK for Go. It tokenizes, parses, and generates ASTs from SQL with zero-copy optimizations and intelligent object pooling - handling 1.38M+ operations per second with sub-microsecond latency.
// v1.15+ recommended entry point: ParseTree returns an opaque Tree,
// so you don't need to import pkg/sql/ast just to get started.
tree, _ := gosqlx.ParseTree(ctx, "SELECT u.name, COUNT(*) FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.name",
gosqlx.WithDialect("postgresql"))
fmt.Println("Tables:", tree.Tables())
fmt.Println(tree.Format(gosqlx.WithIndent(2), gosqlx.WithUppercaseKeywords(true)))Why GoSQLX?
Not an ORM - a parser. You get the AST, you decide what to do with it.
Not slow - zero-copy tokenization, sync.Pool recycling, no allocations on hot paths.
Not limited - PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite, Snowflake, ClickHouse. CTEs, window functions, MERGE, set operations.
Not just a library - CLI, VS Code extension, GitHub Action, MCP server, WASM playground, Python bindings.
Related MCP server: mcp-server-duckdb
Get Started in 60 Seconds
go get github.com/ajitpratap0/GoSQLXpackage main
import (
"fmt"
"github.com/ajitpratap0/GoSQLX/pkg/gosqlx"
)
func main() {
ctx := context.Background()
// ParseTree (v1.15+) is the recommended entry point. It returns an
// opaque handle with built-in helpers โ no need to import pkg/sql/ast.
tree, err := gosqlx.ParseTree(ctx, "SELECT id, name FROM users WHERE active = true",
gosqlx.WithDialect("postgresql"))
if err != nil {
// Sentinel errors work with errors.Is
if errors.Is(err, gosqlx.ErrSyntax) {
log.Fatalf("syntax error: %v", err)
}
log.Fatal(err)
}
fmt.Println("Tables:", tree.Tables())
fmt.Println(tree.Format(gosqlx.WithIndent(2), gosqlx.WithUppercaseKeywords(true)))
// Walk the AST โ typed walkers avoid the type-assertion dance:
tree.WalkSelects(func(s *ast.SelectStatement) bool {
fmt.Printf(" SELECT with %d columns\n", len(s.Columns))
return true
})
// The legacy Parse/Format/Validate API still works for v1.x code.
// See docs/MIGRATION.md for the Tree migration guide.
}Install Everywhere
๐ฆ Go Library
go get github.com/ajitpratap0/GoSQLX๐ฅ๏ธ CLI Tool
go install github.com/ajitpratap0/GoSQLX/cmd/gosqlx@latest
gosqlx validate "SELECT * FROM users"
gosqlx format query.sql
gosqlx lint query.sql๐ป VS Code Extension
code --install-extension ajitpratap0.gosqlxBundles the binary - zero setup. Learn more โ
๐ค MCP Server (AI Integration)
claude mcp add --transport http gosqlx \
https://mcp.gosqlx.dev/mcp7 SQL tools in Claude, Cursor, or any MCP client. Guide โ
Features at a Glance
Documentation
Resource | Description | |
๐ | Website with interactive playground | |
๐ | Parse your first SQL in 5 minutes | |
๐ | Comprehensive patterns and examples | |
๐ | Complete API documentation | |
๐ฅ๏ธ | Command-line tool reference | |
๐ | Dialect support matrix | |
๐ค | AI assistant integration | |
๐๏ธ | System design deep-dive | |
๐ | Performance data and methodology | |
๐ | What's new in each version |
Contributing
GoSQLX is built by contributors like you. Whether it's a bug fix, new feature, documentation improvement, or just a typo - every contribution matters.
git clone https://github.com/ajitpratap0/GoSQLX.git && cd GoSQLX
task check # fmt โ vet โ lint โ test (with race detection)Fork & branch from
mainWrite tests - we use TDD and require race-free code
Run
task check- must pass before PROpen a PR - we review within 24 hours
๐ Contributing Guide ยท ๐ Code of Conduct ยท ๐๏ธ Governance
Who's Using GoSQLX?
GoSQLX is downloaded and cloned by developers worldwide -- 595 unique cloners in just 14 days. If you're using GoSQLX in your project or organization, we'd love to hear about it!
Project / Company | Use Case |
Your project here |
Using GoSQLX at work? Building something cool with it? Share your story in GitHub Discussions -- it helps the community grow and motivates continued development.
Community
Got questions? Ideas? Found a bug?
License
Apache License 2.0 - see LICENSE for details.
Built with โค๏ธ by the GoSQLX community
gosqlx.dev ยท Playground ยท Docs ยท MCP Server ยท VS Code
If GoSQLX helps your project, consider giving it a โญ
Maintenance
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ajitpratap0/GoSQLX'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
