示例#1
0
// NewQbsStoreFromDSN creates a *QbsStore from a DSN; DSNs can be created
// directly with ParamsToDSN or from the environment with GetDSNOrDie, via
// the DATABASE_URL environment var.
func NewQbsStoreFromDSN(dsn *qbs.DataSourceName) *QbsStore {
	qbs.RegisterWithDataSourceName(dsn)
	result := &QbsStore{
		Dsn:    dsn,
		Policy: NewQbsDefaultOrmTransactionPolicy(),
	}
	return result
}
示例#2
0
文件: k.go 项目: rose312/mzr
func main() {
	dsn := new(qbs.DataSourceName)
	dsn.Password = "******"
	dsn.Username = "******"
	dsn.DbName = "pgsql"
	dsn.Dialect = qbs.NewPostgres()
	qbs.RegisterWithDataSourceName(dsn)
	dsn.Append("sslmode", "disable")
	qbs.SetConnectionLimit(10, false)
	mg, err := qbs.GetMigration()
	if err != nil {
		fmt.Println(err)
	}
	mg.Log = true
	mg.CreateTableIfNotExists(new(Process))
	http.HandleFunc("/", do)
	http.ListenAndServe(":80", nil)
}