示例#1
0
func initDbMap() *gorp.DbMap {
	dbmap = db.InitDb("postgres://jjhageman@localhost:5432/devstatus_test?sslmode=disable")
	dbmap.TraceOn("", log.New(os.Stdout, "gorptest: ", log.Lmicroseconds))
	dbmap.AddTableWithName(Dev{}, "devs").SetKeys(true, "ID")
	err := dbmap.CreateTablesIfNotExists()
	checkErr(err, "Create tables failed")
	return dbmap
}
示例#2
0
func init() {
	//url := os.Getenv("HEROKU_POSTGRESQL_COPPER_URL")
	//url += " sslmode=require"
	url := "postgres://jjhageman@localhost:5432/devstatus?sslmode=disable"
	dbmap = db.InitDb(url)
	// add a table, setting the table name to 'posts' and
	// specifying that the Id property is an auto incrementing PK
	dbmap.AddTableWithName(Dev{}, "devs").SetKeys(true, "ID")

	// create the table. in a production system you'd generally
	// use a migration tool, or create the tables via scripts
	err := dbmap.CreateTablesIfNotExists()
	checkErr(err, "Create tables failed")
}