# Reading data from data base

**URL:** <https://forum.rasa.com/t/reading-data-from-data-base/43011>\
**Category:** Rasa Open Source\
**Created:** [April 29, 2021, 8:37am UTC](https://forum.rasa.com/t/reading-data-from-data-base/43011 "2021-04-29T08:37:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ghaith](https://avatars.discourse-cdn.com/v4/letter/g/cab0a1/32.png) [@Ghaith](https://forum.rasa.com/u/Ghaith)\
**Post date:** [April 29, 2021, 8:37am UTC](https://forum.rasa.com/t/reading-data-from-data-base/43011/1 "2021-04-29T08:37:35Z")

</div>

Hi ,

in my project, i tried to collect data from user and store it in to SQL database

Can anyone help me with an example where Rasa is connected to sql database / Mongo Db for reading Data . Suppose i have collected an employee table with all the details from user, now i need the Bot to read the data from there and utter to the user

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [April 29, 2021, 2:39pm UTC](https://forum.rasa.com/t/reading-data-from-data-base/43011/2 "2021-04-29T14:39:40Z")

</div>

You can read data from a database as with any Python code using the [Python MySQL Connector](https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html).

Write the code as if it was standalone and unrelated to Rasa. Then, copy that code into a custom action (in the `run()` method of the action), and use `dispatcher.utter_message(...)` to display your results.

---

<div class="post-metadata">

**Author:** ![joggerjoel](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/joggerjoel/32/14583_2.png) [@joggerjoel](https://forum.rasa.com/u/joggerjoel)\
**Post date:** [April 29, 2021, 3:47pm UTC](https://forum.rasa.com/t/reading-data-from-data-base/43011/3 "2021-04-29T15:47:07Z")

</div>

import pymysql import pymysql.cursors

# pip install mysqlclient

> <https://stackoverflow.com/questions/4960048/how-can-i-connect-to-mysql-in-python-3-on-windows>

This works well with unicode.
