1.xorm参数说明:xorm help reverse
usage: xorm reverse [-s] driverName datasourceName tmplPath [generatedPath] [tableFilterReg]
according database’s tables and columns to generate codes for Go, C++ and etc.
-s Generated one go file for every table
driverName Database driver name, now supported four: mysql mymysql sqlite3 postgres
datasourceName Database connection uri, for detail infomation please visit driver's project page
tmplPath Template dir for generated. the default templates dir has provide 1 template
generatedPath This parameter is optional, if blank, the default value is model, then will
generated all codes in model dir
tableFilterReg Table name filter regexp
2.将数据库内表导出为go文件
xorm reverse -s mysql root:root@/chatting?charset=utf8 E:\work\go\src\github.com\go-xorm\cmd\xorm\templates\goxorm
其中:
-s 导出表结构在同一个go文件中;没有此参数,将每个表导出不同为不同的go文件
mysql 为数据库驱动名
root:root@/chatting?charset=utf8,root/root为数据库用户名和密码,chatting为将要导出的数据库名
E:\work\go\src\github.com\go-xorm\cmd\xorm\templates\goxorm,为xorm导出的模板路径名;
因为输出目录缺省,所以会在命令执行的当前目录下生成model文件夹