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 Started
import "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})
A+Go Report
MITLicense
1.24.0+Go Version
v1.0.3Latest Release

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.

FeatureDescriptionLink
Query StatementsMulti-record retrieval with WHERE, ORDER BY, LIMIT, OFFSET, DISTINCT, GROUP BY, and HAVING.Statements
Select StatementsSingle-record lookups with optional row-level locking (FOR UPDATE, FOR SHARE).Statements
Update StatementsTargeted modifications with SET clauses and WHERE conditions. Returns the updated record.Statements
Aggregate StatementsCOUNT, SUM, AVG, MIN, MAX with optional filtering and grouping.Statements
Batch & TransactionsBulk inserts, updates, and deletes. Transaction variants with full isolation for atomic operations.Concepts
LLM IntegrationSelf-describing statements with validation and dispatch patterns for AI-driven database access.LLM Integration

Articles

Browse the full edamame documentation.

OverviewStatement-driven query exec for Go applications

Learn

QuickstartGet started with edamame in minutes
Core ConceptsExecutors, statements, and specs - the building blocks of edamame
ArchitectureHow edamame works with soy for SQL generation

Guides

StatementsDefining and using typed database statements
TestingTesting strategies for edamame-based applications

Cookbook

LLM IntegrationUsing edamame statements with AI assistants

Reference

API ReferenceComplete API reference for the edamame package