如何在redash中导入Python库

2024-05-15 01:58:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我在redash中添加Python作为数据源, 但当进口'MySQL.connector'模块I出错:

我看了这篇文章: 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()

我得到这个错误

Error running query: <type 'exceptions.AttributeError'> 'module' object has no attribute 'connector'


Tags: readsqlconnectorasmysql数据源sumspeed

热门问题