How can I install MySQL in my rasa environment?

Hi There,

How can I install MySQL in my rasa virtual environment? I am using MacOS with Rasa version 2.8.2

thanks in advance!!

@deepali0162 What is your usecase and why you want to install MySQL in rasa environment ? can you elaborate more?

@nik202 I want to store the data entered by user via a form into a database so that it could be used later for modification. I have installed MySQL Workbench 8.0 on my system(Mac OS) already.

@deepali0162 Right!

@deepali0162 you just want to store the the bot/user convocation in any database ? or user input in events: user

For storing the bot/user conversation you can use tracker store:

Update this code in endpoints.yml

For Postgres:

tracker_store:
   type: SQL
   dialect: "postgresql"  # the dialect used to interact with the db
   url: "localhost"  # (optional) host of the sql db, e.g. "localhost"
   db: "chatbot"  # path to your db
   username: "postgres"  # username used for authentication
   password: "123"  # password used for authentication
   # query: # optional dictionary to be added as a query string to the connection URL
   #   driver: my-driver

For MySQL:

tracker_store:
   type: SQL
   dialect: "mysql+pymysql"  # the dialect used to interact with the db
   url: "localhost"  # (optional) host of the sql db, e.g. "localhost"
   db: "rasa"  # path to your db
   username: "root"  # username used for authentication
   password: "root"  # password used for authentication

Note: You also can need to install psycopg2-binary and pymysql. You will see when it will thrown error.

@deepali0162 You need to create a database schema i.e rasa (or whatever you feel like) and update same in db: rasa, train the bot and run rasa and rasa actions in separate terminals; whilst running you will get above mention errors or some other please install in your conda environment and again train and follow the process.

Note: Your WorkBench 8.0 should be open at backend Hope this will solve your issue. Good Luck!

My Workbench is running in the backend. I have added the code in endpoint.yml and then installed psycopg2-binary and pymysql using called pip install psycopg2-binary and pip install pymysqlโ€ฆ I have retrained my model, updated db name and running rasa actions. But Iโ€™m getting error for the cmd- pip install mysql or no output for the cmd - mysql -u root -p

Please help.

@deepali0162 Nice, if you did the following steps? You canโ€™t install MySQL like this sorry. If you want to see the store conversation you have to go to your .db schema which you have mentioned in endpoints.yml and then go to table and select the rows and you will be able to see the stored data. I hope you got my pointers? If you have any issue do let me know.

@nik202 didnโ€™t understoodโ€ฆhave to go to your .db schem

@deepali0162 share your endpoints.yml tracker store for MySQL please.

endpoints.yml (1.7 KB)

I have configured the connections and have created attached database_connectivity.py file to insert data in my database from rasa form. I am inputting all the data but same is not getting reflected in the database in mysql. database_connectivity.py (786 Bytes)

how to check if my rasa is connected to the database?

@deepali0162 It should shown you in the --debug mode, what command you are using rasa to chat with your bot? do you have any front end?

@deepali0162 open your WorkBench SQL > go to rasa_db > Click on table and select the row to see the data.

Did you understand this points? Yes or No?

@nik202 ,

  1. It is not showing me getting connected to database in --debug mode.
  2. I am using rasa shell to run the bot as of now else Rasa X.
  3. I have selected the rows from database and found now rows are inserted.

@deepali0162 If it not showing you anything on mysql then itโ€™s not connected and its not storing bot/user conversations.

@nik202 thank you!!