Skip to content

About

Comprehensive sqlc configuration template for all project types

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

139 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

template-sqlc

CI Status

Coverage

GitHub Stars GitHub Forks GitHub Issues

Go Reference License Go Version

🚀 The Ultimate sqlc Configuration Template - Production-ready, comprehensive sqlc configuration template that works for ALL project types. Takes advantage of EVERY sqlc feature with real working plugins and validated configurations.

Table of Contents

Overview

This is a comprehensive, production-ready sqlc configuration template that supports SQLite, PostgreSQL, and MySQL databases. It provides fully configured code generation with all sqlc features, including multi-language plugins (Python, Kotlin, TypeScript), CEL validation rules for production safety, and 30+ type mapping patterns for common domain needs.

Features

  • 🛡️ Production Safety CEL validation rules prevent dangerous queries (SELECT *, DELETE without WHERE)

  • ⚡ Multi-Database Excellence SQLite/Turso, PostgreSQL, MySQL - comprehensive support with isolated configurations

  • 🎨 Code Generation Mastery All emit_* options configured with detailed explanations and trade-offs

  • 🔧 Real Working Plugins Verified Python, Kotlin, TypeScript plugins with actual SHA256 hashes

  • 🌍 Universal Project Support 10+ project type templates from hobby to enterprise scale

  • 📊 Comprehensive Type Overrides 30+ real-world type mapping patterns for domain-specific needs

  • ✅ Production Validated Based on analysis of 21+ real projects, sqlc vet verified

  • 🎯 Smart Configuration Management Environment variables, build tags, conditional compilation support

Quick Start

# Clone this repository
git clone https://github.com/LarsArtmann/template-sqlc.git
cd template-sqlc

# Copy the configuration to your project
cp sqlc.yaml /path/to/your/project/

# Set up example schemas (optional)
make examples

# Generate your Go code
sqlc generate

Installation

Prerequisites

Quick Install

# Install sqlc (macOS)
brew install sqlc

# Install sqlc (Linux)
curl -L https://github.com/kyleconroy/sqlc/releases/latest/download/sqlc_$(uname -s)_$(uname -m).tar.gz | tar -xz -C /usr/local/bin sqlc

# Verify installation
sqlc version

Usage

1. Basic Setup

# Create your project structure
mkdir -p sql/{sqlite,postgres,mysql}/{queries,schema}

# Add your schema files
echo "CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT);" > sql/sqlite/schema/001_users.sql

# Add your queries
echo "-- name: GetUser :one\nSELECT * FROM users WHERE id = ?;" > sql/sqlite/queries/user.sql

# Generate Go code
sqlc generate

2. Using the Template

# Copy the comprehensive configuration
cp sqlc.yaml your-project/

# Uncomment your database configuration
# Edit paths and database URLs

# Validate and generate
sqlc compile  # Validate syntax
sqlc generate  # Generate Go code

3. Examples

See the examples/ directory for complete, working examples with:

  • User management schemas
  • Database-specific features (FTS, JSON, Enums)
  • Optimized queries and indexes
  • Session management patterns

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Test your changes: sqlc compile && sqlc vet
  4. Commit your changes: git commit -m 'Add amazing feature'
  5. Push to the branch: git push origin feature/amazing-feature
  6. Open a Pull Request

Development Guidelines

  • Test thoroughly: Ensure sqlc compile passes
  • Add comments: Explain WHY each setting is chosen
  • Consider trade-offs: Document performance/flexibility implications
  • Keep universal: Avoid domain-specific hardcoded values

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Lars Artmann - https://lars.software

Project Link: https://github.com/LarsArtmann/template-sqlc

About

Comprehensive sqlc configuration template for all project types

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages