Skip to content

Repository files navigation

Gorose ORM

GoDocGo Report CardGittergorose-orm

Official Website | (官方网站)

https://gohouse.github.io/gorose

Documentation

What is Gorose?

Gorose, a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developers and python or ruby developers.
Currently provides five major database drivers:

Quick Preview

// select * from users where id=1 limit 1db.Table("users").Where("id",1).First()
// select id as uid,name,age from users where id=1 order by id desc limit 10db.Table("users").Where("id",1).Fields("id as uid,name,age").Order("id desc").Limit(10).Get()
// query stringdb.Query("select * from user limit 10")
db.Execute("update users set name='fizzday' where id=?", 1)

Features

  • Chain Operation
  • Connection Pool

Requirement

  • Golang 1.6+
  • Glide (optional, dependencies management for golang)

Installation

  • standard:
goget-ugithub.com/gohouse/gorose
glidegetgithub.com/gohouse/gorose

Base Usage

package main
import (
"github.com/gohouse/gorose"//import Gorose
_ "github.com/go-sql-driver/mysql"//import DB driver"fmt"
)
// DB Config.(Recommend to use configuration file to import)varDbConfig=map[string]interface{}{
// Default database configuration"Default": "mysql_dev",
// (Connection pool) Max open connections, default value 0 means unlimit."SetMaxOpenConns": 300,
// (Connection pool) Max idle connections, default value is 1."SetMaxIdleConns": 10,
// Define the database configuration character "mysql_dev"."Connections":map[string]map[string]string{
"mysql_dev": map[string]string{
"host": "192.168.200.248",
"username": "gcore",
"password": "gcore",
"port": "3306",
"database": "test",
"charset": "utf8",
"protocol": "tcp",
"prefix": "", // Table prefix"driver": "mysql", // Database driver(mysql,sqlite,postgres,oracle,mssql)
},
},
}
funcmain() {
connection, err:=gorose.Open(DbConfig)
iferr!=nil {
fmt.Println(err)
return
}
// close DBdeferconnection.Close()
db:=connection.GetInstance()
res,err:=db.Table("users").First()
iferr!=nil {
fmt.Println(err)
return
}
fmt.Println(res)
}

For more usage, please read the Documentation.

License

MIT

Contribution

release notes

0.9.0

  • new seperate db instance

0.8.2

  • improve config format, new config format support file config like json/toml etc.

0.8.1

  • improve multi connection and nulti transation

0.8.0

  • add connection pool
  • adjust dir for open source standard
  • add glide version control
  • translate for english and chinese docment

About

Gorose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides five major database drivers: mysql,sqlite3,postgres,oracle,mssql.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages