Back to list
kalbasit

sqlc

by kalbasit

Nix binary cache proxy service -- with local caching and signing.

241🍴 10📅 Jan 23, 2026

SKILL.md


name: sqlc description: Working with sqlc and database queries

SQLC Skill

This skill provides instructions for working with sqlc and database queries in the NCPS repository. NCPS supports multiple database engines (SQLite, PostgreSQL, MySQL), and sqlc is used to generate type-safe Go code from SQL queries for each engine.

Configuration

  • SQLC Config: sqlc.yml
  • Queries:
    • SQLite: db/query.sqlite.sql
    • PostgreSQL: db/query.postgres.sql
    • MySQL: db/query.mysql.sql
  • Output:
    • SQLite: pkg/database/sqlitedb
    • PostgreSQL: pkg/database/postgresdb
    • MySQL: pkg/database/mysqldb

Workflow for Query Changes

Any time a query file (db/query.<engine>.sql) is updated, you MUST follow these steps:

1. Generate SQLC Code

Run the sqlc generate command to update the generated Go files for all engines.

sqlc generate

2. Regenerate Database Wrappers and Models

Run go generate for the pkg/database package. This command uses gen-db-wrappers to automatically:

  1. Extract the Querier interface from the postgresdb backend.
  2. Generate the common Querier interface in pkg/database/querier.go.
  3. Generate common domain models in pkg/database/models.go.
  4. Generate database wrappers (wrapper_sqlite.go, wrapper_postgres.go, wrapper_mysql.go).
go generate ./pkg/database

[!IMPORTANT] Do NOT manually edit pkg/database/querier.go or pkg/database/models.go. They are fully automated.

Best Practices

  • Consistency: Ensure that equivalent queries exist for all supported engines unless the feature is engine-specific.

  • Linting: Use sqlfluff to lint and format SQL files before running sqlc generate.

    sqlfluff lint db/query.*.sql
    sqlfluff format db/query.*.sql
    

Score

Total Score

70/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

+5
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon