增加 pre_dst_exec 配置,可以在目标库执行pre sql
diff --git a/convert-example.json b/convert-example.json
index d1a2b4b..2053606 100755
--- a/convert-example.json
+++ b/convert-example.json
@@ -38,6 +38,7 @@
                         OPENDATE, CLOSEDATE, CARDVERNO, LASTSAVED",

         "remark": "导入卡表前更新 begin_time 不能为空",

         "pre_exec" : ["update ykt_cur.t_pif_card set begin_time='20061001' where card_id=43430"],

+        "dst_pre_exec": ["update t_card where cardid=10"],

         "post_exec": ["update t_card set cardphytype=20"]

     }

 ]

diff --git a/v2convert.py b/v2convert.py
index 178aef9..d23a210 100755
--- a/v2convert.py
+++ b/v2convert.py
@@ -12,7 +12,7 @@
 import re

 

 

-VERSION = "1.3"

+VERSION = "1.4"

 SYSENCODING = locale.getdefaultlocale()[1]

 

 if not SYSENCODING:

@@ -180,6 +180,14 @@
                     return False

                 self._src_db.commit()

 

+        if 'pre_dst_exec' in rule:

+            for statment in rule['pre_dst_exec']:

+                if not self._do_execute_sql(self._dst_db.cursor, statment):

+                    print u"执行 pre_dst_exec 语句失败"

+                    self._dst_db.rollback()

+                    return False

+                self._dst_db.commit()

+

         if not self._do_execute_sql(query_cursor, rule['src_sql']):

             print u"查询原始数据失败"

             return False