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 file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#!/bin/bash
#
#
#
host = "172.23.64.1" #數據庫所在地址。默認是localhost
port = 3306 #數據庫所在端口。默認是3306
user = "root" #數據庫的用戶名
password = "admin" #密碼
db = "prodio" #要同步的數據庫名。要同步多個db可以將本腳本複製多份
api_key = "6609532c2f496383893d8fd9dfddf3611656642534" #api_key
api_token = "dcd833347fb245662a872ea056b1e8ef81705506" #api_token
cat_name = "03資料庫" #可選。如果想把生成的文檔都放在項目的子目錄下,則這裡填寫子目錄名。
url = "http://nas.zltest.com.tw:7999/server/?s=/api/open/updateDbItem" #可選。同步到的url。如果是使用www.showdoc.com.cn , 則不需要再改此項。如果是部署私有版版showdoc, 請改此項為http://xx.com/server/index.php?s=/api/open/updateDbItem 。其中xx.com為你的部署域名
#
#
#
#
#
#
export MYSQL_PWD = ${ password }
COMMAND = " set names utf8;select TABLE_NAME ,TABLE_COMMENT from tables where TABLE_SCHEMA =' ${ db } ' "
declare table_info = ` mysql -h${ host } -P${ port } -u${ user } --show-warnings= false -D information_schema -e " ${ COMMAND } " `
#echo $table_info
COMMAND = " set names utf8;select TABLE_NAME ,COLUMN_NAME, COLUMN_DEFAULT ,IS_NULLABLE ,COLUMN_TYPE ,COLUMN_COMMENT from COLUMNS where TABLE_SCHEMA =' ${ db } ' "
declare table_detail = ` mysql -h${ host } -P${ port } -u${ user } --show-warnings= false -D information_schema -e " ${ COMMAND } " `
#echo $table_detail
table_info2 = ${ table_info //&/_this_and_change_ }
table_detail2 = ${ table_detail //&/_this_and_change_ }
curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' " ${ url } " --data-binary @- <<CURL_DATA
from=shell&table_info=${table_info2}&table_detail=${table_detail2}&api_key=${api_key}&api_token=${api_token}&cat_name=${cat_name}
CURL_DATA
export MYSQL_PWD = ""