func SetupDb() (q *qbs.Qbs) {
	var (
		err       error
		migration *qbs.Migration
	)

	q, err = qbs.GetQbs()

	if q, err = qbs.GetQbs(); err != nil {
		panic(err)
	}

	if migration, err = qbs.GetMigration(); err != nil {
		panic(err)
	}
	defer migration.Close()

	if err = migration.CreateTableIfNotExists(new(User)); err != nil {
		panic(err)
	}

	if err = migration.CreateTableIfNotExists(new(Profile)); err != nil {
		panic(err)
	}

	return q
}
Exemple #2
0
func CreateUserTable() error {
	migration, err := qbs.GetMigration()
	if err != nil {
		return err
	}
	defer migration.Close()
	return migration.CreateTableIfNotExists(new(User))
}
Exemple #3
0
func CreateTable(structPtr interface{}) error {
	migration, err := qbs.GetMigration()
	if err != nil {
		return err
	}
	defer migration.Close()
	return migration.CreateTableIfNotExists(structPtr)
}
func UstvariTabeloSporocila() error {
	migration, err := qbs.GetMigration()
	if err != nil {
		return err
	}
	defer migration.Close()
	return migration.CreateTableIfNotExists(new(Sporocilo))
}
Exemple #5
0
// 初始化数据库
func RegisterDb() {
	qbs.Register("mysql", DBSPEC, DBNAME, qbs.NewMysql())
	// 创建数据库
	m, err := qbs.GetMigration()
	if err != nil {
		panic(err)
	}
	defer m.Close()

	m.CreateTableIfNotExists(new(models.User))
	m.CreateTableIfNotExists(new(models.Project))
	m.CreateTableIfNotExists(new(models.UserCode))
	m.CreateTableIfNotExists(new(models.UserStatus))
	m.CreateTableIfNotExists(new(models.OAuth))
}
Exemple #6
0
func CreateTabel() error {
	migration, err := qbs.GetMigration()
	if err != nil {
		return err
	}
	defer migration.Close()

	err = migration.CreateTableIfNotExists(new(User))
	err = migration.CreateTableIfNotExists(new(Category))
	err = migration.CreateTableIfNotExists(new(Topic))
	err = migration.CreateTableIfNotExists(new(Reply))
	err = migration.CreateTableIfNotExists(new(Permissions))

	return err
}
Exemple #7
0
//初始化表
func initTable() error {
	migration, err := qbs.GetMigration()
	if err != nil {
		return err
	}
	defer migration.Close()

	err = migration.CreateTableIfNotExists(new(models.User))
	err = migration.CreateTableIfNotExists(new(models.Person))
	err = migration.CreateTableIfNotExists(new(models.Episode))
	/*err = migration.CreateTableIfNotExists(new(models.Reply))
	err = migration.CreateTableIfNotExists(new(models.Permissions))*/

	return err
}
Exemple #8
0
func main() {
	qbs.Register("postgres", "user=postgres password=jn!@#$%^&* dbname=pgsql sslmode=disable", "pgsql", qbs.NewPostgres())
	m, _ := qbs.GetMigration()
	//m.Log = true
	//m.DropTable(new(Topic))
	m.CreateTableIfNotExists(new(Topic))

	q, _ := qbs.GetQbs()
	//q.Log = true
	i := new(Topic)
	i.Content = "i am test!!!!!!"
	q.Save(i)

	nana, _ := FindNaById(q, 1)
	fmt.Println(nana)
}
Exemple #9
0
Fichier : k.go Projet : 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)
}
func SetupDb() (q *qbs.Qbs) {
	var (
		err       error
		migration *qbs.Migration
	)

	qbs.SetLogger(log.New(os.Stdout, "query:", log.Lmicroseconds), log.New(os.Stdout, "error:", log.Lmicroseconds))

	q, err = qbs.GetQbs()

	if q, err = qbs.GetQbs(); err != nil {
		panic(err)
	}

	if migration, err = qbs.GetMigration(); err != nil {
		panic(err)
	}
	defer migration.Close()
	if err = migration.CreateTableIfNotExists(new(User)); err != nil {
		panic(err)
	}

	return q
}
Exemple #11
0
func SetMg() (mg *qbs.Migration, err error) {
	RegisterDb()
	mg, err = qbs.GetMigration()
	return mg, err
}
Exemple #12
0
func setMg() (*qbs.Migration, error) {
	mg, err := qbs.GetMigration()
	return mg, err
}