Statement-Driven Query Execution for Go. Define Once, Execute Anywhere.
Typed, named database operations as pure data structures. Compile-time safety, parameterized execution, and multi-dialect support without raw SQL strings.
Get Startedimport "github.com/zoobz-io/edamame"
// Define statements once at package level
var (
ByStatus = edamame.NewQueryStatement(
"by-status", "Query users by status",
edamame.QuerySpec{
Where: []edamame.ConditionSpec{
{Field: "status", Operator: "=", Param: "status"},
},
OrderBy: []edamame.OrderBySpec{
{Field: "created_at", Direction: "desc"},
},
Limit: ptr(50),
},
)
SelectByID = edamame.NewSelectStatement(
"select-by-id", "Select user by ID",
edamame.SelectSpec{
Where: []edamame.ConditionSpec{
{Field: "id", Operator: "=", Param: "id"},
},
},
)
)
// Execute with type safety — wrong statement type won't compile
users, _ := exec.ExecQuery(ctx, ByStatus, map[string]any{"status": "active"})
user, _ := exec.ExecSelect(ctx, SelectByID, map[string]any{"id": 123})Why Edamame?
The middle ground between raw SQL strings and heavy ORMs.
Typed Statements
QueryStatement goes to ExecQuery, SelectStatement to ExecSelect. The compiler enforces correct pairing.
Injection-Proof by Construction
Field names validated against schema, operators checked against allowlist, values bound as parameters. No interpolation.
Declarative Specs
Queries defined as Go structs, not builder chains or string templates. Inspect, compose, and serialize them.
Multi-Dialect Support
Same statements render to PostgreSQL, MariaDB, SQLite, or SQL Server. Swap the renderer, keep the logic.
LLM-Ready Metadata
Statements carry names, descriptions, and parameter specs. Serialize to JSON for AI-assisted database operations.
Thread-Safe Execution
Statements are immutable data. Concurrent execution with no shared mutable state.
Capabilities
Five statement types covering the full range of database operations — all type-safe, all parameterized.
| Feature | Description | Link |
|---|---|---|
| Query Statements | Multi-record retrieval with WHERE, ORDER BY, LIMIT, OFFSET, DISTINCT, GROUP BY, and HAVING. | Statements |
| Select Statements | Single-record lookups with optional row-level locking (FOR UPDATE, FOR SHARE). | Statements |
| Update Statements | Targeted modifications with SET clauses and WHERE conditions. Returns the updated record. | Statements |
| Aggregate Statements | COUNT, SUM, AVG, MIN, MAX with optional filtering and grouping. | Statements |
| Batch & Transactions | Bulk inserts, updates, and deletes. Transaction variants with full isolation for atomic operations. | Concepts |
| LLM Integration | Self-describing statements with validation and dispatch patterns for AI-driven database access. | LLM Integration |
Articles
Browse the full edamame documentation.