我正在使用python驱动程序(mysql.connector)并执行以下操作:
_db_config = {
'user': 'root',
'password': '1111111',
'host': '10.20.30.40',
'database': 'ddb'
}
_connection = mysql.connector.connect(**_db_config) # connect to a remote server
_cursor = _connection.cursor(buffered=True)
_cursor.execute("""SELECT * FROM database LIMIT 1;""")
在某些情况下,对_cursor.execute()的调用会挂起,没有异常
顺便说一下,当连接到本地MySQL服务器时似乎没问题
答案 0 :(得分:0)
由于大型数据库或未优化的查询,结果可能会挂起。 你可以尝试以下事情
这是一个与" pymysql"一起工作的帖子。 Gives small idea to with with mysql and python3
答案 1 :(得分:-1)
转移到MySQLdb(而不是mysql.connector)解决了所有问题: - )