首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何导入redash中的Python库

如何导入redash中的Python库
EN

Stack Overflow用户
提问于 2019-06-23 08:19:04
回答 1查看 495关注 0票数 0

我在redash中添加了Python作为数据源,但是当导入'MySQL.connector‘模块时,我会得到一个错误:

我遵循这篇文章:http://kzkohashi.hatenablog.com/entry/2017/12/09/224516

代码语言:javascript
复制
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()

我知道这个错误

运行查询错误:‘模块’‘对象没有属性’连接器‘

EN

回答 1

Stack Overflow用户

发布于 2019-06-23 08:23:52

装置好像坏了。

试试这个:

代码语言:javascript
复制
pip uninstall mysql-connector
pip uninstall mysql-connector-python

然后是这个:

代码语言:javascript
复制
pip install mysql-connector
# OR
pip install mysql-connector-python

然后:

代码语言:javascript
复制
import mysql.connector 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56722177

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档