go语言的beedb
2016-07-21 00:00
274 查看
摘要: go语言的数据库orm:beedb简介
关于go语言的orm:beedb网上资料太少了,今天才开始研究,总结了一些,希望对大家有帮助,不说没用的了,直接主题:
安装:
go get github.com/astaxie/beedb
API地址: https://github.com/astaxie/beedb/wiki/API-Interface 支持的数据库种类:
Mysql/SQLite/PostgreSQL/DB2/MS ADODB/ODBC/Oracle
数据库包下载地址:
Mysql:github.com/ziutek/mymysql/godrv[*]
Mysql:github.com/Go-SQL-Driver/MySQL[*]
PostgreSQL:github.com/bmizerany/pq[*]
SQLite:github.com/mattn/go-sqlite3[*]
DB2: bitbucket.org/phiggins/go-db2-cli
MS ADODB: github.com/mattn/go-adodb[*]
ODBC: bitbucket.org/miquella/mgodbc[*]
Oracle: github.com/mattn/go-oci8
Model struct:
Db *sql.DB
TableName string
LimitStr int
OffsetStr int
WhereStr string
ParamStr []interface{}
OrderStr string
ColumnStr string
PrimaryKey string
JoinStr string
GroupByStr string
HavingStr string
Model method:
func New(db *sql.DB) (m Model) *
* Add New sql.DB in the future i will add ConnectionPool.Get()
func (orm *Model) DelectRow() (int64, error)
func (orm *Model) Delete(output interface{}) (int64, error)
func (orm *Model) DeleteAll(rowsSlicePtr interface{}) (int64, error)
func (orm *Model) Execute(finalQueryString string, args ...interface{}) (sql.Result, error) Execute sql
func (orm *Model) Find(output interface{}) error
func (orm *Model) FindAll(rowsSlicePtr interface{}) error
func (orm *Model) FindMap() (resultsSlice []map[string][]byte, err error)
func (orm *Model) GroupBy(keys string) *Model
func (orm *Model) Having(conditions string) *Model
func (orm *Model) Insert(properties map[string]interface{}) (int64, error) inert one info
func (orm *Model) InsertBatch(rows []map[string]interface{}) ([]int64, error) insert batch info
func (orm *Model) Join(join_operator, tablename, condition string)
The join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (orm *Model) Limit(start int, size ...int) *Model
func (orm *Model) Offset(offset int) *Model
func (orm *Model) OrderBy(order string) *Model
func (orm *Model) SacnPK(output interface{}) *Model
func (orm *Model) Save(output interface{}) interface{} if the struct has PrimaryKey == 0 insert else update
func (orm *Model) Select(colums string) *Model
func (orm *Model) SetPK(pk string) *Model
func (orm *Model) SetTable(tbname string) *Model
func (orm *Model) Update(properties map[string]interface{}) (int64, error) update info
func (orm *Model) Where(querystring interface{}, args ...interface{}) *Model
关于go语言的orm:beedb网上资料太少了,今天才开始研究,总结了一些,希望对大家有帮助,不说没用的了,直接主题:
安装:
go get github.com/astaxie/beedb
API地址: https://github.com/astaxie/beedb/wiki/API-Interface 支持的数据库种类:
Mysql/SQLite/PostgreSQL/DB2/MS ADODB/ODBC/Oracle
数据库包下载地址:
Mysql:github.com/ziutek/mymysql/godrv[*]
Mysql:github.com/Go-SQL-Driver/MySQL[*]
PostgreSQL:github.com/bmizerany/pq[*]
SQLite:github.com/mattn/go-sqlite3[*]
DB2: bitbucket.org/phiggins/go-db2-cli
MS ADODB: github.com/mattn/go-adodb[*]
ODBC: bitbucket.org/miquella/mgodbc[*]
Oracle: github.com/mattn/go-oci8
Model struct:
Db *sql.DB
TableName string
LimitStr int
OffsetStr int
WhereStr string
ParamStr []interface{}
OrderStr string
ColumnStr string
PrimaryKey string
JoinStr string
GroupByStr string
HavingStr string
Model method:
func New(db *sql.DB) (m Model) *
* Add New sql.DB in the future i will add ConnectionPool.Get()
func (orm *Model) DelectRow() (int64, error)
func (orm *Model) Delete(output interface{}) (int64, error)
func (orm *Model) DeleteAll(rowsSlicePtr interface{}) (int64, error)
func (orm *Model) Execute(finalQueryString string, args ...interface{}) (sql.Result, error) Execute sql
func (orm *Model) Find(output interface{}) error
func (orm *Model) FindAll(rowsSlicePtr interface{}) error
func (orm *Model) FindMap() (resultsSlice []map[string][]byte, err error)
func (orm *Model) GroupBy(keys string) *Model
func (orm *Model) Having(conditions string) *Model
func (orm *Model) Insert(properties map[string]interface{}) (int64, error) inert one info
func (orm *Model) InsertBatch(rows []map[string]interface{}) ([]int64, error) insert batch info
func (orm *Model) Join(join_operator, tablename, condition string)
The join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
func (orm *Model) Limit(start int, size ...int) *Model
func (orm *Model) Offset(offset int) *Model
func (orm *Model) OrderBy(order string) *Model
func (orm *Model) SacnPK(output interface{}) *Model
func (orm *Model) Save(output interface{}) interface{} if the struct has PrimaryKey == 0 insert else update
func (orm *Model) Select(colums string) *Model
func (orm *Model) SetPK(pk string) *Model
func (orm *Model) SetTable(tbname string) *Model
func (orm *Model) Update(properties map[string]interface{}) (int64, error) update info
func (orm *Model) Where(querystring interface{}, args ...interface{}) *Model
相关文章推荐
- ASP也使用ORM,给ASP上所有的SQL注入画上句号
- 仿orm自动生成分页SQL分享
- Go语言入门教程之Arrays、Slices、Maps、Range操作简明总结
- GO语言异常处理机制panic和recover分析
- go语言执行windows下命令行的方法
- Go语言计算两个经度和纬度之间距离的方法
- Go语言排序与接口实例分析
- Go语言导出内容到Excel的方法
- go语言实现sqrt的方法
- Go语言MessageBox用法实例
- Go语言判断指定文件是否存在的方法
- 深入理解:单一入口、MVC、ORM、CURD、ActiveRecord概念
- go语言制作的zip压缩程序
- go语言channel实现多核并行化运行的方法
- Go语言MD5加密用法实例
- go语言使用scp的方法实例分析
- Go语言中的switch用法实例分析
- go语言检测文件是否存在的方法
- Go语言里的结构体文法实例分析
- Go语言结构体定义和使用方法