Skip to content

SQLC is a database tool to generate idiomatic type-safe go code that derived from our own SQL Queries.

Notifications You must be signed in to change notification settings

21Rachit/SQLC_Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLC-basic-test

SQLC is a database tool to generate idiomatic type-safe go code that derived from our own SQL Queries.

It is basically an alternative for GORM in golang

Install packages-->

  1. sqlc

    curl -LO https://downloads.sqlc.dev/sqlc_1.25.0_linux_amd64.tar.gz

    tar xzf sqlc_1.25.0_linux_amd64.tar.gz

    ./sqlc version

    /home/rachit/sqlc version

  2. migrate

    curl -LO https://github.com/golang-migrate/migrate/releases/download/v4.17.0/migrate.linux-arm64.tar.gz

    tar xzf migrate.linux-arm64.tar.gz

    ./migrate -version

    /home/rachit/migrate version

Commands to run-->

  1. /home/rachit/sqlc generate --> this creates a folder named db which contains 3 files db.go, models.go and query.sql.go

  2. /home/rachit/migrate create -ext sql -dir misc/migrations CreateAuthor --> this create a folder named misc/migrations which has sql.up and sql.down schema file

  3. /home/rachit/migrate -source "file://misc/migrations" -database "postgres://dbuser:rachit@localhost:5432/testdb?sslmode=disable" up --> this creates a table in the postgres database

  4. go run main.go --> this starts the golang application which inserts data in the table

About

SQLC is a database tool to generate idiomatic type-safe go code that derived from our own SQL Queries.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages