# Problems of inputting user data to mysql

**URL:** <https://forum.rasa.com/t/problems-of-inputting-user-data-to-mysql/68568>\
**Category:** Rasa Open Source\
**Created:** [March 6, 2026, 4:07pm UTC](https://forum.rasa.com/t/problems-of-inputting-user-data-to-mysql/68568 "2026-03-06T16:07:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![haydn04](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@haydn04](https://forum.rasa.com/u/haydn04)\
**Post date:** [March 6, 2026, 4:10pm UTC](https://forum.rasa.com/t/problems-of-inputting-user-data-to-mysql/68568/2 "2026-03-06T16:10:26Z")

</div>

```
def validate_username(self, slot_value: Any, dispatcher: CollectingDispatcher, tracker: Tracker, domain:DomainDict) -> Dict\[Text, Any\]:

    

    name = str(slot_value)

    new = tracker.get_slot('new')

    try:

        connect= mysql.connector.connect(host="localhost",user="root",password="",database="restaurant")

        if connect.is_connected:

            cursor = connect.cursor(dictionary=True)

            query = "SELECT username FROM user WHERE username = %s"

            cursor.execute(query,(name,))

            row = cursor.fetchall()

            if not all(char.isalpha() for char in name):

                dispatcher.utter_message("name should be english")

                return {"username": None}

            elif new:

                if len(row) == 0:

                    return {"username": name}

                else:

                    dispatcher.utter_message("name was used")

                    return {"username": None}

            else:

                if len(row) == 0:

                    dispatcher.utter_message("wrong name, please input again")

                    return {"username": None}

                else:

                    return {"username": name}

            

    except Error as e:

        dispatcher.utter_message("error_checkname")

    return \[\]

```

here is the part of the class ValidateUserLogin

---

_[View the full topic](https://forum.rasa.com/t/problems-of-inputting-user-data-to-mysql/68568)._
