mirror of
https://github.com/owncast/owncast.git
synced 2025-11-01 10:55:57 +08:00
SQL Queries
sqlc generates type-safe code from SQL. Here's how it works:
- You define the schema in
schema.sql. - You write your queries in
query.sqlusing regular SQL. - You run
sqlc generateto generate Go code with type-safe interfaces to those queries. - You write application code that calls the generated code.
Only those who need to create or update SQL queries will need to have sqlc installed on their system. It is not a dependency required to build the codebase.
Using sqlc
This project uses Go 1.24's native tool management. The sqlc tool is already defined in go.mod.
After cloning the repository, ensure tools are downloaded:
go mod download
Then run sqlc:
go tool sqlc generate
Managing Tool Versions
To upgrade sqlc to a specific version:
go get -tool github.com/sqlc-dev/sqlc/cmd/sqlc@latest
To check the current version:
go list -m github.com/sqlc-dev/sqlc