Hi guys, I have a problem with my bot. I connected it with a DB for a simple query. The query’s purpose is to show a casual result after matching 2 slots (rasa) with 2 fields of table in db. The problem is that in the terminal where I run “rasa run actions”, I see the occurence found , while in the terminal where I run “rasa shell” the bot crashes for asyncio.exceptions.TimeoutError :
If I stop the terminal with CTRL+C , an other message appears:
for message_part in text.strip().split("\n\n"):
AttributeError: ‘list’ object has no attribute ‘strip’
Can you help me, please?
This is the code:
class ActionMatchEvents(Action):
def name(self):
return "action_match_events" # Be careful, did you mean action_fetch_data?
def run(self, dispatcher, tracker, domain):
luogo = tracker.get_slot("luogo")
preferenza = tracker.get_slot("preferenza")
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="itourist")
mycursor = mydb.cursor()
sql = f'SELECT Risultato FROM itourist.riscontro WHERE Luogo="{luogo}" AND Preferenza="{preferenza}" ORDER BY RAND() LIMIT 1;'
try:
#Execute the SQL Query
mycursor.execute(sql)
#result = mycursor.query(sql)
result = mycursor.fetchall()
#Now print fetched data
print("OCCURRENCE FOUND")
print(result)
dispatcher.utter_message(text=result)
return []
except:
dispatcher.utter_message("Error : Unable to fetch data.")
return []
```