我在redash中添加了Python作为数据源,但是当导入'MySQL.connector‘模块时,我会得到一个错误:
我遵循这篇文章:http://kzkohashi.hatenablog.com/entry/2017/12/09/224516
def read_sql():
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passwd="******",database="testing")
mycursor = mydb.cursor()
mycursor.execute("select hour,sum(temperature) as temperature ,sum(wind_speed) as wind_speed from weatherdaat group by hour")
myresult = mycursor.fetchall()
for x in myresult:
print(x[0],x[1],x[2])
read_sql()我知道这个错误
运行查询错误:‘模块’‘对象没有属性’连接器‘
发布于 2019-06-23 08:23:52
装置好像坏了。
试试这个:
pip uninstall mysql-connector
pip uninstall mysql-connector-python然后是这个:
pip install mysql-connector
# OR
pip install mysql-connector-python然后:
import mysql.connector https://stackoverflow.com/questions/56722177
复制相似问题