执行下面脚本,可以将字典转换为符合DolphinDB 规范的JSON 格式数据,放到一个JSON文件中。
connDict = dict(`ip`port`db`uid`pwd`driver, [`192.168.xxx.xxx, `xxxxx, `xxxx, `user, "passwd", `MySQL]) toJson(connDict)
自定义函数,读取JSON文件并转化为字典。
def getMysqlConnDictFromJson(filePath) { f = file(filePath) arr = f.readLines() json = reduce(concat, trim(arr[arr != string(NULL)])) return fromJson(json) } connDict = getMysqlConnDictFromJson("/data/software/dolphin/server/mysqlconn.json")