1、创建存放表名文件

#一行一个表名
mkdir table_list

2、创建存放生成的canal脚本目录

mkdir result

3、脚本代码

#!/bin/bash
cat table_list | while read line 
do 
touch result/$line.yml
cat >>result/$line.yml <<EOF
dataSourceKey: dragnet
destination: dragnet
groupId: dragnet
outerAdapterKey: dragnet
concurrent: true
dbMapping:
  database: dragnet
  table: $line
  targetTable: dragnet.$line
  targetPk:
    id: id
  targetColumns:
EOF
mysql -h localhost -uroot -p password   -e "desc dragnet.$line;"   2>/dev/null |grep -v "Field"|awk '{print "    "$1":"}' >>result/$line.yml
done

 

相关文章:

  • 2021-10-03
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2022-12-23
  • 2021-11-29
相关资源
相似解决方案