Introduction
Xorm [10] [11] is a simple and powerful ORM for Go.
Features
- Struct <-> Table Mapping Support
- Chainable APIs
- Transaction Support
- Both ORM and raw SQL operation Support
- Sync database schema Support
- Query Cache speed up
- Database Reverse support, See Xorm Tool README
- Simple cascade loading support
- Optimistic Locking support
Drivers Support
Drivers for Go’s sql package which currently support database/sql includes:
- Mysql: github.com/go-sql-driver/mysql [1]
- MyMysql: github.com/ziutek/mymysql/godrv [2]
- Postgres: github.com/lib/pq [3]
- Tidb: github.com/pingcap/tidb [4]
- SQLite: github.com/mattn/go-sqlite3 [5]
- MsSql: github.com/denisenkom/go-mssqldb [6]
- MsSql: github.com/lunny/godbc [7]
- Oracle: github.com/mattn/go-oci8 [8]
- ql: github.com/cznic/ql [9]
Installation
If you have gopm
installed
gopm get github.com/go-xorm/xorm
Or use go get
go get github.com/go-xorm/xorm
Run and setup
- Init orm:
orm, err := xorm.NewEngine("sqlite3", "./test.db")
- Sync database structs:
err = orm.Sync(new(User), new(Article))