Skip to content

zsmj-xu/postgres

 
 

Repository files navigation

GORM PostgreSQL Driver

Quick Start

import (
  "github.com/zsmj-xu/driver/postgres"
  "github.com/zsmj-xu/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{})

Configuration

import (
  "github.com/zsmj-xu/driver/postgres"
  "github.com/zsmj-xu/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.

About

GORM PostgreSQL driver

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%