MCPcopy Index your code
hub / github.com/ajitpratap0/GoSQLX

github.com/ajitpratap0/GoSQLX @v1.14.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.14.0 ↗ · + Follow
6,308 symbols 34,448 edges 653 files 3,641 documented · 58%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GoSQLX

GoSQLX Logo

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.

ast, _ := gosqlx.Parse("SELECT u.name, COUNT(*) FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.name")
// → Full AST with statements, columns, joins, grouping - ready for analysis, transformation, or formatting

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.

Get Started in 60 Seconds

go get github.com/ajitpratap0/GoSQLX
package main

import (
    "fmt"
    "github.com/ajitpratap0/GoSQLX/pkg/gosqlx"
)

func main() {
    // Parse any SQL dialect
    ast, _ := gosqlx.Parse("SELECT * FROM users WHERE active = true")
    fmt.Printf("%d statement(s)\n", len(ast.Statements))

    // Format messy SQL
    clean, _ := gosqlx.Format("select id,name from users where id=1", gosqlx.DefaultFormatOptions())
    fmt.Println(clean)
    // SELECT
    //   id,
    //   name
    // FROM users
    // WHERE id = 1

    // Catch errors before production
    if err := gosqlx.Validate("SELECT * FROM"); err != nil {
        fmt.Println(err) // → expected table name
    }
}

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.gosqlx
Bundles the binary - zero setup. [Learn more →](https://gosqlx.dev/vscode/) ### 🤖 MCP Server (AI Integration)
claude mcp add --transport http gosqlx \
  https://mcp.gosqlx.dev/mcp
7 SQL tools in Claude, Cursor, or any MCP client. [Guide →](https://gosqlx.dev/docs/mcp_guide/)

Features at a Glance

⚡ Parser

Zero-copy tokenizer Recursive descent parser Full AST generation Multi-dialect engine

🛡️ Analysis

SQL injection scanner 10 lint rules (L001–L010) Query complexity scoring Metadata extraction

🔧 Tooling

AST-based formatter Query transforms API VS Code extension GitHub Action

🌐 Multi-Dialect

PostgreSQL · MySQL · MariaDB SQL Server · Oracle SQLite · Snowflake · ClickHouse

🤖 AI-Ready

MCP server (7 tools) Public remote endpoint Streamable HTTP

🧪 Battle-Tested

20K+ concurrent ops Zero race conditions ~85% SQL-99 compliance

Documentation

Resource Description
🌐 gosqlx.dev Website with interactive playground
🚀 Getting Started Parse your first SQL in 5 minutes
📖 Usage Guide Comprehensive patterns and examples
📄 API Reference Complete API documentation
🖥️ CLI Guide Command-line tool reference
🌍 SQL Compatibility Dialect support matrix
🤖 MCP Guide AI assistant integration
🏗️ Architecture System design deep-dive
📊 Benchmarks Performance data and methodology
📝 Release Notes 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)
  1. Fork & branch from main
  2. Write tests - we use TDD and require race-free code
  3. Run task check - must pass before PR
  4. Open 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 Add yourself via PR or tell us in Discussions

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?

Discussions Issues Blog

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 ⭐

Extension points exported contracts — how you extend this code

Visitor (Interface)
Visitor defines an interface for traversing the AST using the visitor pattern. The Visitor interface enables systematic [10 …
pkg/sql/ast/visitor.go
Loader (Interface)
Loader connects to a live database and reads its schema metadata. Dialect-specific implementations are provided in pkg/s [3 …
pkg/schema/db/loader.go
TestingT (Interface)
TestingT is an interface wrapper around *testing.T to allow for mocking in tests. It includes the methods used by the he [1 …
pkg/gosqlx/testing/testing.go
Rule (Interface)
Rule defines the interface that all linting rules must implement. Rules check SQL content at various levels (text, toke
pkg/linter/rule.go
RewriteRule (FuncType)
RewriteRule is a function that mutates an AST statement in-place to rewrite dialect-specific constructs. It returns an e
pkg/transpiler/transpiler.go
Rule (Interface)
Rule represents an AST rewrite rule that can be applied to a single SQL statement. Rules modify the AST in-place and ret
pkg/transform/transform.go
Rule (Interface)
Rule defines the interface that all optimization rules must implement. Each rule inspects a single AST statement and re
pkg/advisor/optimizer.go
BinaryResolutionResult (Interface)
(no doc)
vscode-extension/src/utils/binaryResolver.ts

Core symbols most depended-on inside this repo

Errorf
called by 3711
pkg/gosqlx/testing/testing.go
Fatalf
called by 2261
pkg/gosqlx/testing/testing.go
Run
called by 1366
pkg/lsp/server.go
advance
called by 828
pkg/sql/parser/parser.go
isType
called by 691
pkg/sql/parser/parser.go
Error
called by 502
pkg/errors/errors.go
Error
called by 423
pkg/sql/parser/recovery.go
ReleaseAST
called by 373
pkg/sql/ast/pool.go

Shape

Function 4,068
Method 1,533
Struct 504
Interface 70
Class 64
TypeAlias 64
FuncType 5

Languages

Go90%
TypeScript7%
Python3%

Modules by API surface

pkg/sql/ast/ast.go363 symbols
pkg/sql/ast/sql.go80 symbols
pkg/sql/ast/pool.go79 symbols
pkg/formatter/render_test.go73 symbols
pkg/lsp/protocol.go70 symbols
pkg/sql/ast/data_type.go68 symbols
pkg/advisor/rules_advanced.go66 symbols
pkg/advisor/advisor_advanced_test.go56 symbols
pkg/advisor/rules.go55 symbols
vscode-extension/src/test/unit/errorRecovery.test.ts53 symbols
pkg/gosqlx/extract_test.go53 symbols
pkg/sql/ast/create_table_builder.go52 symbols

Datastores touched

(mysql)Database · 1 repos
dbDatabase · 1 repos
mydbDatabase · 1 repos

For agents

$ claude mcp add GoSQLX \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact