Beispiel #1
0
func connDb() *qbs.Qbs {
	db := qbs.GetFreeDB()
	if db == nil {
		// 'sql.Open' only returns error when unknown driver, so it's not necessary to check in other places.
		db, _ = sql.Open(_SQLITE3_DRIVER, DB_NAME)
	}

	q := qbs.New(db, qbs.NewSqlite3())
	return q
}
Beispiel #2
0
func GetQbs() (q *qbs.Qbs, err error) {
	db := qbs.GetFreeDB()
	if db == nil {
		db, err = OpenDb()
		if err != nil {
			return nil, err
		}
	}
	q = qbs.New(db, qbs.NewMysql())
	return q, nil
}
Beispiel #3
0
func ConnDb() (q *qbs.Qbs, err error) {
	db := qbs.GetFreeDB()
	if db == nil {
		db, err = OpenDb(dbtypeset)
		if err != nil {
			return nil, err
		}
	}

	switch {
	case dbtypeset == "sqlite":
		q = qbs.New(db, qbs.NewSqlite3())

	case dbtypeset == "mysql":
		q = qbs.New(db, qbs.NewMysql())

	case dbtypeset == "pgsql":
		q = qbs.New(db, qbs.NewPostgres())

	}
	return q, nil
}