Command line tools for database operation written by Go. Use reverse instead.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
Lunny Xiao 9ccdb0ebed
continuous-integration/drone/push Build is passing Details
upgrade to xorm v1.0.1
2 years ago
vendor upgrade to xorm v1.0.1 2 years ago
xorm upgrade to xorm v1.0.1 2 years ago
.drone.yml lunny/update_drone (#67) 3 years ago
.gitignore upgrade to xorm v1.0.1 2 years ago
LICENSE Initial commit 9 years ago upgrade to xorm v1.0.1 2 years ago Upgrade xorm to v0.8.0 (#74) 3 years ago
go.mod upgrade to xorm v1.0.1 2 years ago
go.sum upgrade to xorm v1.0.1 2 years ago


xorm tools

Please use reverse to instead of this tool.

xorm tools is a set of tools for database operation.

Source Install

go get

and you will install the depends below:

** For sqlite support, you need build via go build -tags sqlite3 because of this driver ask cgo.


All the commands below.

  • reverse reverse a db to codes
  • shell a general shell to operate all kinds of database
  • dump dump database all table struct's and data to standard output
  • source execute a sql from std in
  • driver list all supported drivers


Reverse command is a tool to convert your database struct to all kinds languages of structs or classes. After you installed the tool, you can type

xorm help reverse

to get help


cd $GOPATH/src/

sqlite: xorm reverse sqite3 test.db templates/goxorm

mysql: xorm reverse mysql root:@/xorm_test?charset=utf8 templates/goxorm

mymysql: xorm reverse mymysql xorm_test2/root/ templates/goxorm

postgres: xorm reverse postgres "dbname=xorm_test sslmode=disable" templates/goxorm

mssql: xorm reverse mssql "server=test;user id=testid;password=testpwd;database=testdb" templates/goxorm

will generated go files in ./model directory

Template and Config

Now, xorm tool supports go and c++ two languages and have go, goxorm, c++ three of default templates. In template directory, we can put a config file to control how to generating.


lang must be go or c++ now. genJson can be 1 or 0, if 1 then the struct will have json tag.


Shell command provides a tool to operate database. For example, you can create table, alter table, insert data, delete data and etc.

xorm shell sqlite3 test.db will connect to the sqlite3 database and you can type help to list all the shell commands.


Dump command provides a tool to dump all database structs and data as SQL to your standard output.

xorm dump sqlite3 test.db could dump sqlite3 database test.db to standard output. If you want to save to file, just type xorm dump sqlite3 test.db > test.sql.


xorm source sqlite3 test.db < test.sql will execute sql file on the test.db.


List all supported drivers since default build will not include sqlite3.


BSD License