完善错误提示,正确显示oracle提示错误信息
diff --git a/convert-example.json b/convert-example.json
index 10fbaa6..ca691ea 100755
--- a/convert-example.json
+++ b/convert-example.json
@@ -30,7 +30,7 @@
'' frozedate,'0' badflag,'' badtype,'' baddate,'0' lockflag,
'' lockdate,c.begin_time opendate,'' closedate,'' cardverno,'' lastsaved
from YKT_CUR.T_PIF_CARD c left join ykt_cur.t_aif_account a on
- c.card_id=a.card_id left join ykt_cur.t_cif_customer c1 on
+ c.card_id=a.card_id, left join ykt_cur.t_cif_customer c1 on
c.cosumer_id=c1.cut_id order by c.card_id",
"dest_column": "CARDNO, ACCNO, CARDTYPE,CARDPHYTYPE, FEETYPE, CUSTID, SHOWCARDNO,
CARDPHYID, CARDPWD,EXPIREDATE, STATUS, LOSSFLAG, LOSSDATE, LOSSEFTTIME,
diff --git a/dbengine.py b/dbengine.py
index 0ec5c3d..239956b 100644
--- a/dbengine.py
+++ b/dbengine.py
@@ -37,7 +37,7 @@
return True
except Exception, e:
# print u"执行数据失败"
- print str(e)
+ print str(e).decode("utf-8")
return False
def query(self, sql):
diff --git a/v2convert.py b/v2convert.py
index 4c09bd2..5267a16 100755
--- a/v2convert.py
+++ b/v2convert.py
@@ -7,11 +7,12 @@
import json
import locale
import time
+import cx_Oracle
from path import path
import re
-VERSION = "1.1"
+VERSION = "1.3"
SYSENCODING = locale.getdefaultlocale()[1]
if not SYSENCODING:
@@ -82,7 +83,7 @@
sys.exit(1)
current = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- print "启动转换程序 Version: {0}, {1}".format(VERSION, current)
+ print u"启动转换程序 Version: {0}, {1}".format(VERSION, current)
if not self._load_convert_file():
self.die(u"不能加载转换规则文件")
@@ -151,8 +152,17 @@
return True
return True
- except Exception as e:
- print u"执行sql 失败, {0}".format(e)
+ except Exception as exc:
+ try:
+ if isinstance(exc, cx_Oracle.DatabaseError):
+ error, = exc.args
+ msg = error.message.decode(SYSENCODING)
+ else:
+ msg = "{0}".format(exc)
+ print u"执行sql 失败, {0}".format(msg)
+ except UnicodeError:
+ print exc
+ print u"执行语句[{0}]错误".format(statment)
return False
def _do_convert(self, rule):
@@ -193,10 +203,12 @@
insert_sql = 'insert into {0} ({1}) values({2})'.format(rule['name'],
rule['dest_column'], values)
# print insert_sql
+ count += 1
if not self._dst_db.exec_sql(insert_sql):
+ print u"导入第{0}条记录错误".format(count)
self._dst_db.rollback()
return False
- count += 1
+
if count % self._commit_count == 0:
print u"导入数据 {0} 条".format(count)
self._dst_db.commit()