Back to Gems
go-gorm/postgres(opens in a new tab)
Language: Go
GORM PostgreSQL driver
- stars
- 298
- watchers
- 3
- forks
- 158
- open issues
- 32
- Last updated
- 09/15/2026
Language: Go
GORM PostgreSQL driver
import ( "gorm.io/driver/postgres" "gorm.io/gorm" ) // https://github.com/jackc/pgx dsn := "host=localhost user=gorm password=gorm dbname=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai" db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
import ( "gorm.io/driver/postgres" "gorm.io/gorm" ) db, err := gorm.Open(postgres.New(postgres.Config{ DSN: "host=localhost user=gorm password=gorm dbname=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai", // data source name, refer https://github.com/jackc/pgx PreferSimpleProtocol: true, // disables implicit prepared statement usage. By default pgx automatically uses the extended protocol }), &gorm.Config{})
Checkout https://gorm.io for details.