sqlex

Enhance Go database operations with JSON handling, SQL hooks, and automatic rebind.

55|1|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/go-sqlex/sqlex --skill sqlex
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sqlex
Source: https://github.com/go-sqlex/sqlex/tree/main
Command: npx skills add https://github.com/go-sqlex/sqlex --skill sqlex

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires github.com/go-sqlex/sqlex, and includes scripts (resource) and references (resource) components.

What problem does it solve?

sqlex simplifies Go database operations, providing advanced features like structured JSON types, Hook aspects for logging and metrics, and automatic rebind for easier SQL injection prevention.

Core Features & Use Cases

  • Advanced JSON Handling: Generic JSONValue[T] for auto-serialize/deserialize JSON columns.
  • Hook System: Pluggable SQL interceptors for logging, tracing, and metrics.
  • Automatic Rebind: Writes ? uniformly across all databases for easier SQL injection prevention.
  • Use Case: With sqlex, you can write code like db.Get(&user, "SELECT * FROM users WHERE id = ?", 1) which will work across PostgreSQL, MySQL, SQLite, and SQL Server without needing to change the query syntax.

Quick Start

Use sqlex to connect to your database and execute queries:

db, err := sqlex.Connect("sqlite3", ":memory:")
if err != nil {
    log.Fatal(err)
}
defer db.Close()

// Insert a user
_, err = db.Exec("INSERT INTO users (name, email) VALUES (?, ?)", "Alice", "[email protected]")
if err != nil {
    log.Fatal(err)
}

// Query a user
var user User
err = db.Get(&user, "SELECT * FROM users WHERE id = ?", 1)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("User: %+v\n", user)

Frequently Asked Questions about sqlex

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle JSON columns in Go database operations automatically?

Go database operations can handle JSON columns automatically using generic JSONValue[T] types to auto-serialize and deserialize JSON data directly into structs during query execution.

Can I write SQL queries with ? placeholders for PostgreSQL and MySQL in Go?

Yes, automatic rebind writes ? uniformly across PostgreSQL, MySQL, SQLite, and SQL Server, translating placeholders automatically to prevent SQL injection without changing query syntax.

What is the best way to add logging and metrics to Go SQL execution?

Adding logging and metrics to Go SQL execution is best done with pluggable Hook interceptors, which monitor query execution for tracing and performance tracking without altering core logic.

Do I need the sqlex library to use JSONValue and SQL hooks in Go?

Yes, you need the sqlex library dependency to use generic JSONValue[T] types, SQL execution hooks, and automatic rebind features for robust Go database operations.

How do I connect and query a SQLite database in Go using sqlex?

Connect to SQLite in Go using sqlex.Connect("sqlite3", ":memory:"), then execute db.Get or db.Exec queries to insert and retrieve structured records seamlessly.