template-sqlc

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2026 License: MIT

README ΒΆ

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

Directories ΒΆ

Path Synopsis
internal
adapters
Package adapters provides database adapter implementations.
Package adapters provides database adapter implementations.
adapters/converters
Package converters provides type conversion utilities for database operations.
Package converters provides type conversion utilities for database operations.
adapters/mappers
Package mappers provides conversion functions between domain entities and database models.
Package mappers provides conversion functions between domain entities and database models.
adapters/mysql
Package mysql provides MySQL-specific database adapter implementations.
Package mysql provides MySQL-specific database adapter implementations.
adapters/postgres
Package postgres provides PostgreSQL-specific database adapter implementations.
Package postgres provides PostgreSQL-specific database adapter implementations.
adapters/sqlite
Package sqlite provides SQLite-specific database adapter implementations.
Package sqlite provides SQLite-specific database adapter implementations.
adapters/validation
Package validation provides validation utilities for database adapters
Package validation provides validation utilities for database adapters
db
Package db provides database helper utilities.
Package db provides database helper utilities.
db/mysql
Package mysql provides ...
Package mysql provides ...
db/postgres
Package postgres provides ...
Package postgres provides ...
db/shared
Package shared provides common types for database/sql-based packages.
Package shared provides common types for database/sql-based packages.
db/sqlite
Package sqlite provides ...
Package sqlite provides ...
domain/entities
Package entities provides domain entities and error types for the application.
Package entities provides domain entities and error types for the application.
domain/events
Package events provides domain event types and publishing capabilities.
Package events provides domain event types and publishing capabilities.
domain/repositories
Package repositories defines repository interfaces for data access.
Package repositories defines repository interfaces for data access.
domain/services
Package services provides domain service types and DTOs for user management.
Package services provides domain service types and DTOs for user management.
monitoring
Package monitoring provides metrics collection and exposure via Prometheus.
Package monitoring provides metrics collection and exposure via Prometheus.
tests/integration
Package integration provides integration test utilities including mock repositories.
Package integration provides integration test utilities including mock repositories.
validation
Package validation provides input validation utilities for user data.
Package validation provides input validation utilities for user data.
pkg
errors
Package errors provides standardized application error types with HTTP status codes.
Package errors provides standardized application error types with HTTP status codes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL