Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go sqlc

  • sqlc in Go (Golang) is a popular tool that automatically generates type-safe Go code from SQL queries.
  • It helps us write raw SQL queries but then produces Go code that we can call directly, with strong typing and no manual scanning of rows.




Configurations



Return types

  • Suffix after the colon (:) tells sqlc what kind of result to expect from the query.
  • Most common options are:

Suffix Meaning Return Type in Go
:one Returns exactly one row (Type, error)
:many Returns multiple rows ([]Type, error)
:exec Executes the query (no rows returned) (sql.Result, error) or error
:execrows Executes query and returns number of affected rows (int64, error)
:copyfrom Uses COPY FROM for bulk inserts (PostgreSQL) Used for batch inserts (Postgres-only)

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages