使用 Python 在 Caché 和 Sql Server 之间同步数据

任务目标:抽取 Caché 中的数据,导入 Sql Server 中。

遇到的问题:

1、UnicodeEncodeError: ‘ascii’ codec can’t encode characters in……

当程序中出现非ascii编码时,python 的处理常常会报这样的错。补救代码如下:

stdi,stdo,stde=sys.stdin,sys.stdout,sys.stderr
reload(sys)
sys.stdin,sys.stdout,sys.stderr=stdi,stdo,stde
sys.setdefaultencoding('utf8')

以上代码的解释可参考:http://blog.csdn.net/love_rongrong/article/details/17119261 和 http://blog.csdn.net/kxcfzyk/article/details/41414247?utm_source=tuicool

2、SQL 语句中一定不能出现中文,不然会导致 Python 崩溃。

原文地址:https://www.cnblogs.com/NaughtyBaby/p/4875965.html