Files
Crimson-Gatekeeper/srv/internal/common/database-client.go
2026-01-13 00:08:49 +08:00

22 lines
400 B
Go

package common
import (
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func GetDataBaseClient() *gorm.DB {
dsn := "host=localhost " +
"user=gatekeeper " +
"dbname=crimson " +
"sslmode=disable " +
"port=5432 " +
"password=crimson " +
"connect_timeout=20 "
client, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
if err != nil {
panic("无法连接数据库")
}
return client
}