@nik202 don’t load from .csv, i load directly from mySql
Connect to Database (MySQL)
mydb = mysql.connector.connect(
host=“localhost”,
user=“",
password=" ***”,
database=“chatbot”,
auth_plugin=‘mysql_native_password’)
mycursor = mydb.cursor()
class ActionSearchDocument(Action):
def name(self) -> Text:
return "action_search_document"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
name_document = tracker.get_slot("name_document")
print(name_document)
query_begin = "SELECT name FROM document"
mycursor.execute(query_begin)
result_query_begin = mycursor.fetchall()
result_match = match_entites(name_document,result_query_begin)
print(result_match)
#write query
query_end = "SELECT name, link, date FROM document WHERE name = '" + result_match + "'"
mycursor.execute(query_end)
myresult = mycursor.fetchall()
dispatcher.utter_message(text=f"Đây là link tài liệu {result_match} mà bạn đang cần: ", json_message = myresult)
return []
match_entites i use fuzzywuzzy as you instructed and it works great.
nik202
(NiK202)
August 5, 2021, 9:56pm
44
@longnguyenQB I am giving you hint/ logic, please try it as I not remember the code, but run it right now ok
SELECT CONVERT(CAST(name as BINARY) USING utf8) as name FROM document
SELECT name, CAST(CONVERT(name USING utf8) AS binary)
FROM document
WHERE name=.............................;
I not understand your where command.
@longnguyenQB Are you anywhere using excel or .csv file to push into SQL database?
@longnguyenQB Name the SQL database you using?
@longnguyenQB There can be an endless solution, like SQL Editor Query, Web browser , HTTP etc etc
@nik202 I think the problem here is not the query, it’s the JSON. This is the result of actions.py:
And here is the result when run Rasa Shell:
nik202
(NiK202)
August 5, 2021, 10:41pm
46
@longnguyenQB you data coming from where, database so how it can be JSON? I asked above some questions, can you reply that also? see my above post and answer.
ChrisRahme
(Chris Rahmé)
August 6, 2021, 6:25am
47
longnguyenQB:
mydb = mysql.connector.connect( host=“localhost”, user=““, password=” ***”, database=“chatbot”, auth_plugin=‘mysql_native_password’)
Try to do
mydb = mysql.connector.connect(host="localhost", user="...", password="...", database="chatbot", auth_plugin="mysql_native_password", charset="utf8")
It it doesn’t work, try out all the answers from this post: unicode - Writing UTF-8 String to MySQL with Python - Stack Overflow
1 Like
@ChrisRahme thank you very much! again you helped me to solve my problem.
1 Like
ChrisRahme
(Chris Rahmé)
August 9, 2021, 8:32am
49
Glad to know. Please mark the answer that helped you as solution to close the thread
hi! how do i mark the answer to close the thread?
nik202
(NiK202)
August 10, 2021, 10:08am
51
@longnguyenQB Hi, I guess you need to change the Topic to only Rasa Open Source and delete feedback on rasa open source. Good Luck!
ChrisRahme
(Chris Rahmé)
August 10, 2021, 11:21am
52
Under my answer you should see " Solution". Click on it to close the thread.
And as Nik said, please also change the topic.
nik202
(NiK202)
August 10, 2021, 11:53am
53
@longnguyenQB Till you not changed, you can’t see the tick at any solution.
1 Like
@nik202 sorry I can’t bookmark Solution for both of you, wish I could bookmark it for you. Thank you very much for your enthusiastic help, thank you for accompanying me in the process of building the chatbot. Thanks very much!!
2 Likes
@ChrisRahme thank you very much, thanks to you i solved my problem!!!
1 Like
ermarkar
(Sunil Garg)
August 11, 2021, 4:45am
59
i dont want to spam the post, its not about 10 minute wait… .most of the question are pending from many days, its just nobody answers… thats why!!! and please dont need to be that rude, i wil delete the comment
nik202
(NiK202)
August 11, 2021, 9:22am
61
1 Like