zoukankan      html  css  js  c++  java
  • Centos7使用python3连接inception报错解决办法

    inception支持mysqldb库但不支持pymysql库,无奈mysqldb库不兼容py3,直接使用pymysql 连接inception报错如下:

    ValueError: invalid literal for int() with base 10: 'Inception2'
    

    需要修改pymysql源码修改connections.py及 cursors.py文件

    # find / -name "connections.py"
    # find / -name "cursors.py"
    

    connections.py文件修改:
    781行:

     781     def _request_authentication(self):
     782         # https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse
     783         #if int(self.server_version.split('.', 1)[0]) >= 5:
     784         #    self.client_flag |= CLIENT.MULTI_RESULTS
     785         try:
     786             if int(self.server_version.split('.', 1)[0]) >= 5:
     787                 self.client_flag |= CLIENT.MULTI_RESULTS
     788         except:
     789             if self.server_version.split('.', 1)[0] == 'Inception2':
     790                 self.client_flag |= CLIENT.MULTI_RESULTS
    

    cursors.py文件修改:
    355行:

    355     def _show_warnings(self):
    356         if self._warnings_handled:
    357             return
    358         self._warnings_handled = True
    359         #if self._result and (self._result.has_next or not self._result.warning_count):
    360         if self._result:
    361             return
    

    修改完后可用。

  • 相关阅读:
    大数据总结
    spark_streaming_微批量处理
    spark_sql_解析器
    spark_sql_函数
    spark-sql-04-spark连接hive的几种方式
    spark-sql-04-on_hive
    spark-sql-04-hive
    CF550C Divisibility by Eight
    CF489C Given Length and Sum of Digits...
    CF550A Two Substrings
  • 原文地址:https://www.cnblogs.com/aresxin/p/1w3rwf.html
Copyright © 2011-2022 走看看