Shan
(Shanthosh)
June 21, 2021, 11:07am
1
Hi,
I’m a newbie. Can anyone tell me how to access or retrieve data from SQLite database ( user asks the status of their ticket and bot fetches the status of the ticket from database). I have followed Retail demo bot but in that project BOT replies a message. I want to print entire row. Thanks in advance.
earroyoh
(Enrique Arroyo-Hermosilla)
June 21, 2021, 7:44pm
2
Check rasa livecoding videos and examples done by @rctatman personal_website_bot .
nik202
(NiK202)
June 21, 2021, 9:06pm
3
nik202
(NiK202)
June 30, 2021, 4:49pm
5
@Shan Not get you? Can you share some screenshot and process you followed?
nik202
(NiK202)
June 30, 2021, 5:04pm
7
Shan:
helpers.py”, line 656, in exit raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError
@Shan Did you created some sqlite connection file or you mentioned directly in actions file?
@Shan Did you have too much data to read ?
nik202
(NiK202)
June 30, 2021, 5:18pm
9
@Shan I hope you imported this right?
import sqlite3
from sqlite3 import Error
@Shan Try give relative path copy eng.db in the same file.
conn = create_connection(“eng.db”)
Can be a permission issue.
Shan
(Shanthosh)
July 1, 2021, 4:32am
10
I changed the path but it didn’t work.
nik202
(NiK202)
July 1, 2021, 8:37am
11
@Shan Can you share that snippet code again with all import libraries files. Thanks
nik202
(NiK202)
July 1, 2021, 11:05am
13
Shan:
("C:/Users/SHANVIJ/rasacb/actions/eng.db")
@Shan I hope you changed this path (“C:/Users/SHANVIJ/rasacb/actions/eng.db”) and copy the eng.db in actions folder with action.py file + eng.db and simply give “eng.db”.
@Shan Change this user _details_form to action_details_form (change this in domain.yml file also)
nik202
(NiK202)
July 1, 2021, 1:09pm
15
@Shan Great!! Can you share the updated code for the others? It will help other user. It can be your Rasa Version also. It good you solved it.
Shan
(Shanthosh)
July 2, 2021, 5:03am
16
db = database file path
class ActionQuery(Action):
def name(self) -> Text:
return "action_query"
def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict[Text, Any]]:
connection = sqlite3.connect(db)
cursor = connection.cursor()
Qtno = [tracker.get_slot("tno")]
cursor.execute("SELECT * FROM englishdata WHERE TicketId=?", Qtno)
data_row = cursor.fetchall()
if len(list(data_row)) < 1:
dispatcher.utter_message('Your ticket Id is not in database')
else:
for row in random.sample(data_row, 1):
dispatcher.utter_message(f'{row[0]}')