示例#1
0
func DefaultUserData() (*UserData, error) {
	db := pg.Connect(&pg.Options{
		User: "******",
	})
	user := new(UserData)
	user.db = db
	err := user.Init()

	return user, err
}
示例#2
0
func Test_Init(t *testing.T) {
	db := pg.Connect(&pg.Options{
		User: "******",
	})
	user := new(UserData)
	user.db = db
	err = user.Init()
	if err != nil {
		t.Fatal(err.Error())
		return
	}
	testUserDB = user
}
示例#3
0
文件: main.go 项目: jackc/go_db_bench
func openPg(config pgx.ConnPoolConfig) (*gopg.DB, error) {
	var options gopg.Options

	options.Host = config.Host
	_, err := os.Stat(options.Host)
	if err == nil {
		options.Network = "unix"
		if !strings.Contains(options.Host, "/.s.PGSQL.") {
			options.Host = filepath.Join(options.Host, ".s.PGSQL.5432")
		}
	}

	options.User = config.User
	options.Database = config.Database
	options.Password = config.Password

	return gopg.Connect(&options), nil
}