日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

xorm reverse mysql_xorm 工具

發(fā)布時間:2024/3/24 数据库 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 xorm reverse mysql_xorm 工具 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

# xorm 工具

xorm 是一組數(shù)據(jù)庫操作命令行工具。

### 二進制安裝

如果你安裝了 [got](https://github.com/gobuild/got),你可以輸入如下命令安裝:

~~~

got go-xorm/cmd/xorm

~~~

或者你可以從 [gobuild](http://gobuild.io/download/github.com/lunny/got) 下載后解壓到可執(zhí)行路徑。

### 源碼安裝

`go get github.com/go-xorm/cmd/xorm`

同時你需要安裝如下依賴:

-

github.com/go-xorm/xorm

-

Mysql: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql)

-

MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv)

-

Postgres: [github.com/lib/pq](https://github.com/lib/pq)

-

SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)

** 對于sqlite3的支持,你需要自己進行編譯 `go build -tags sqlite3` 因為sqlite3需要cgo的支持。

### 命令列表

有如下可用的命令:

- **reverse** 反轉(zhuǎn)一個數(shù)據(jù)庫結(jié)構(gòu),生成代碼

- **shell** 通用的數(shù)據(jù)庫操作客戶端,可對數(shù)據(jù)庫結(jié)構(gòu)和數(shù)據(jù)操作

- **dump** Dump數(shù)據(jù)庫中所有結(jié)構(gòu)和數(shù)據(jù)到標準輸出

- **source** 從標注輸入中執(zhí)行SQL文件

- **driver** 列出所有支持的數(shù)據(jù)庫驅(qū)動

### reverse

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

example:

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`

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=go

genJson=1

~~~

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

### Shell

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

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, justtype `xorm dump sqlite3 test.db > test.sql`.

### Source

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

### Driver

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

### LICENSE

BSD License [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/)

總結(jié)

以上是生活随笔為你收集整理的xorm reverse mysql_xorm 工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。