本文整理汇总了Golang中github.com/astaxie/beedb.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: xmain
func xmain() {
db, err := sql.Open("sqlite3", "./httpserver.s3db")
if err != nil {
panic(err)
}
orm = beedb.New(db)
insert()
insertsql()
a := selectone()
fmt.Println(a)
b := selectall()
fmt.Println(b)
update()
updatesql()
findmap()
groupby()
jointable()
deleteone()
deletesql()
deleteall()
}
开发者ID:peterSZW,项目名称:httpserver,代码行数:30,代码来源:db.go
示例2: main
func main() {
db, err := sql.Open("mymysql", "go_test/root/root")
if err != nil {
panic(err)
}
beedb.OnDebug = true
orm := beedb.New(db)
var saveone Userinfo
saveone.Username = "Test Add User"
saveone.Departname = "Test Add Departname"
saveone.Created = time.Now()
orm.Save(&saveone)
add := make(map[string]interface{})
add["username"] = "astaxie"
add["departname"] = "cloud develop"
add["created"] = "2012-12-12"
orm.SetTable("userinfo").Insert(add)
addslice := make([]map[string]interface{})
add := make(map[string]interface{})
add2 := make(map[string]interface{})
add["username"] = "astaxie"
add["departname"] = "cloud develop"
add["created"] = "2020-12-22"
add2["username"] = "astaxie2"
add2["departname"] = "cloud develop2"
add2["created"] = "2012-02-02"
addslice = append(addslice, add, add2)
orm.SetTable("userinfo").Insert(addslice)
}
开发者ID:oywc410,项目名称:MYPG,代码行数:33,代码来源:orm_beedb.go
示例3: main
func main() {
db, err := sql.Open("sqlite3", "./asta.db")
if err != nil {
panic(err)
}
orm = beedb.New(db)
//insert()
//insertsql()
// a := selectone()
// fmt.Println(a)
// b := selectall()
// fmt.Println(b)
// update()
// updatesql()
// findmap()
// groupby()
// jointable()
// delete()
//deletesql()
//deleteall()
}
开发者ID:huaguzi,项目名称:beedb,代码行数:30,代码来源:sqlite.go
示例4: main
func main() {
db, err := sql.Open("sqlite3", DB_PATH)
checkError(err)
orm = beedb.New(db)
var lastIdInserted int64
fmt.Println("Inserting")
lastIdInserted = insertUsingStruct()
insertUsingMap()
a := getOneUserInfo(lastIdInserted)
fmt.Println(a)
b := getAllUserInfo(lastIdInserted)
fmt.Println(b)
fmt.Println("Updating")
updateUserinfo(lastIdInserted)
updateUsingMap(lastIdInserted)
fmt.Println("Querying")
getMapsFromSelect(lastIdInserted)
groupby()
joinTables(lastIdInserted)
fmt.Println("Deleting")
deleteWithUserinfo(lastIdInserted)
deleteRows()
deleteAllUserinfo(lastIdInserted)
}
开发者ID:4honor,项目名称:build-web-application-with-golang,代码行数:30,代码来源:main.go
示例5: GetLink
func GetLink() beedb.Model {
db, err := sql.Open("sqlite3", "./beepkg.db")
if err != nil {
panic(err)
}
orm := beedb.New(db)
return orm
}
开发者ID:JoeyFan,项目名称:beepkg,代码行数:8,代码来源:models.go
示例6: loadDB
func loadDB() {
db, err := sql.Open("sqlite3", "./httpserver.s3db")
if err != nil {
panic(err)
}
orm = beedb.New(db)
}
开发者ID:peterSZW,项目名称:httpserver,代码行数:8,代码来源:api.go
示例7: get_DBFront
/*
Get orm Model
*/
func get_DBFront() beedb.Model {
db, err := sql.Open("sqlite3", db_front)
if !check_err(err) {
panic(err)
}
orm := beedb.New(db)
return orm
}
开发者ID:hngchiming,项目名称:BTCsport,代码行数:11,代码来源:db.go
示例8: RetrieveDB
// Retrieve an instance of the DB.
// REMEMBER TO CLOSE THE DB AFTER USING IT.
func RetrieveDB() (*beedb.Model, error) {
db, err := sql.Open(DBTYPE, DBLOCATION)
if err != nil {
return nil, err
}
orm := beedb.New(db)
return &orm, nil
}
开发者ID:robxu9,项目名称:reservoir,代码行数:10,代码来源:db.go
示例9: FindAll
func (q *MysqlQuery) FindAll(result interface{}) error {
db := q.SlaveDb
orm := beedb.New(db)
if q.Fields == "" {
q.Fields = "*"
}
return orm.SetTable(q.Table).Where(q.Where).OrderBy(q.OrderBy).Limit(q.Size, q.Offset).Select(q.Fields).FindAll(result)
}
开发者ID:ZachBergh,项目名称:common,代码行数:8,代码来源:mysql_v2.go
示例10: GetDB
func GetDB() beedb.Model {
db, e := sql.Open("mysql", "root:[email protected]/golang?charset=utf8")
if e != nil {
println(e.Error())
}
orm := beedb.New(db)
orm.SetTable("weixin")
return orm
}
开发者ID:JessonChan,项目名称:weixinFaWeibo,代码行数:9,代码来源:user.go
示例11: Exec
func (q *MysqlQuery) Exec(newOrm bool, query string, args ...interface{}) (sql.Result, error) {
db := SlaveDb
if newOrm {
db = ConnectMysql(false)
defer db.Close()
}
orm := beedb.New(db)
return orm.Exec(query, args...)
}
开发者ID:ZachBergh,项目名称:common,代码行数:9,代码来源:mysql.go
示例12: InitDb
func InitDb() (orm beedb.Model) {
database := beego.AppConfig.String("mysqldb")
username := beego.AppConfig.String("mysqluser")
password := beego.AppConfig.String("mysqlpass")
db, err := sql.Open("mymysql", database+"/"+username+"/"+password)
Check(err)
orm = beedb.New(db)
return
}
开发者ID:JessonChan,项目名称:seocms,代码行数:9,代码来源:models.go
示例13: openDbConnection
func openDbConnection(engine string, arg_string string) {
db, err := sql.Open(engine, arg_string)
if err != nil {
panic(err)
}
song_db = beedb.New(db, "pg")
}
开发者ID:natemontgomery,项目名称:rvrn,代码行数:9,代码来源:rvrn.go
示例14: Delete
func (q *MysqlQuery) Delete(newOrm bool) (int64, error) {
db := MasterDB
if newOrm {
db = ConnectMysql(true)
defer db.Close()
}
orm := beedb.New(db)
return orm.SetTable(q.Table).Where(q.Where).DeleteRow()
}
开发者ID:ZachBergh,项目名称:common,代码行数:9,代码来源:mysql.go
示例15: InitDb
func InitDb() (orm beedb.Model) {
database := "seocms"
username := "seocms"
password := "helloworld"
db, err := sql.Open("mymysql", database+"/"+username+"/"+password)
Check(err)
orm = beedb.New(db)
return
}
开发者ID:nevernet,项目名称:seocms,代码行数:9,代码来源:models.go
示例16: GetLink
//数据库连接
func GetLink() beedb.Model {
//beedb.OnDebug = true
db, err := sql.Open("mysql", mysql_user+":"+mysql_pass+"@tcp("+mysql_host+":"+mysql_port+")/"+database_name)
if err != nil {
panic(err)
}
orm := beedb.New(db)
return orm
}
开发者ID:hobartcui,项目名称:blogs,代码行数:11,代码来源:admin_models.go
示例17: Upsert
func (q *MysqlQuery) Upsert(data interface{}, newOrm bool) error {
db := MasterDB
if newOrm {
db = ConnectMysql(true)
defer db.Close()
}
orm := beedb.New(db)
return orm.SetTable(q.Table).Save(data)
}
开发者ID:ZachBergh,项目名称:common,代码行数:10,代码来源:mysql.go
示例18: GetLink
func GetLink() beedb.Model {
beedb.OnDebug = true
db, err := sql.Open("mymysql", "test/root/123456")
if err != nil {
panic(err)
}
orm := beedb.New(db)
return orm
}
开发者ID:RandyChou,项目名称:beeblog,代码行数:11,代码来源:model.go
示例19: handleOffer
func handleOffer(offer bondoffer.BondOffer, bond bondoffer.Bond, method string) {
offer.Version = bond.Version
offer.LastVersion = bond.LastVersion
offer.Method = method
offerMap := offer.ToMap()
orm := beedb.New(db)
_, err := orm.SetTable("bond_offer_log").Insert(offerMap)
stomputils.CheckErr(err)
fmt.Println(time.Now(), method, offer.CompanyName, offer.GoodsCode)
}
开发者ID:chinab,项目名称:enterprise-manage,代码行数:12,代码来源:bondofferbak.go
示例20: FindAll
func (q *MysqlQuery) FindAll(result interface{}, newOrm bool) error {
db := SlaveDb
if newOrm {
db = ConnectMysql(false)
defer db.Close()
}
orm := beedb.New(db)
if q.Fields == "" {
q.Fields = "*"
}
return orm.SetTable(q.Table).Where(q.Where).OrderBy(q.OrderBy).Limit(q.Size, q.Offset).Select(q.Fields).FindAll(result)
}
开发者ID:ZachBergh,项目名称:common,代码行数:13,代码来源:mysql.go
注:本文中的github.com/astaxie/beedb.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论