I have a question to the re:dash data source Python. Is it possible to create any Python script and return values to re:dash without calling any other query result? I saw in the Python example that there is a function called add_result_column() but I didn’t understand whether the result parameter must have a specific form or not. If so can you please tell me this specific data form?
Yes, calling other query result is not mandatory, it was just an example.
You do need to set your result in the result
variable and it’s needs to be in the format Redash understands.
See some more reference in this post: http://www.ehfeng.com/redash-python-functions/.
Why does this simple python script not work?
def getData(count):
print "ID Nr. ", count
def getSession():
getData(2)
getSession()
I get the error ‘Error running query: <type ‘exceptions.NameError’> global name ‘getData’ is not defined’
Maybe somebody can help me.
i used python as data source in redash but when import library get error
this is my code
def fun():
import mysql.connector
mydb = mysql.connector.connect(
host=“localhost”,
user=“root”,
passwd=“123speakol”,
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])
fun()
Error running query: <type ‘exceptions.AttributeError’> ‘module’ object has no attribute 'connector’
how to solve it please