template-sqlc

module
v0.0.0-...-ac80cf1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT

README ΒΆ

template-sqlc

CI Status

Coverage Go Report Card

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 project creates professional README templates by analyzing patterns from real-world projects and implementing best practices for documentation. It provides a Go-based generator that creates hierarchical templates for different project types and complexity levels.

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

Jump to

Keyboard shortcuts

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