use postgres in entgo

= "scalecheck:WuLsUDAdDYja@tcp(122.112.186.54:3306)/scalecheck?charset=utf8mb4&parseTime=True&loc=Local"
dsnk8

postgres 創建用戶,創建庫

create user aca with password '';
create database hwapi owner 'aca'; 

在postgresql.conf 中開啓

listen_addresses = '*'

在pg_hba.conf 中允許認證方式,

# TYPE  DATABASE  USER  CIDR-ADDRESS  METHOD
host  all  all 0.0.0.0/0 md5

重啓postgres生效。

ent裏面連接pg

_ "github.com/lib/pq"

client, err := ent.Open("postgres",
	"host=127.0.0.1 port=5432 user=aca dbname=yy password=xxx sslmode=disable")

感覺跟mysql差不多。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章