Search
 
SCRIPT & CODE EXAMPLE
 

SQL

rasa mysql connection custom actions example

from typing import Any, Text, Dict, List

from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import Form, AllSlotsReset, Restarted
import config
import mysql.connector as sql

class ActionPasswordReset(Action):

    def name(self) -> Text:
        return "action_password_reset"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:


        connection = sql.connect(
        host=config.host,
        user=config.user,
        password=config.password,
        database=config.database
        )
        cursor = connection.cursor()
        email = str(tracker.get_slot("email")).lower()
        cursor.execute("Select * from {} where Email='{}' ".format(config.LOGIN_TABLE_NAME, email))
        result = cursor.fetchall()
        if len(result) == 0:
            dispatcher.utter_message("Sorry we couldn't find Email in our database")
        else:
            dispatcher.utter_message("Here is your details: email : {} password: {}".format(result[0][0], result[0][1]))
        # dispatcher.utter_message(text="Hello World!")

        return []
Comment

PREVIOUS NEXT
Code Example
Sql :: order child below the parent in mysqli 
Sql :: sql server set column name as variable 
Sql :: how to list all values of a column that start with a letter in sql 
Sql :: First Step in installing SQL workbench 
Sql :: edad en oracle 
Sql :: trncate table with relationships 
Sql :: will graphql replace sql 
Sql :: delete double on SQL with multiple primary keys 
Sql :: default column value in sql same as other column 
Sql :: postgres multiple left join causing duplicates jsonb_agg 
Sql :: MySQL Age Counter 
Sql :: select * from mysql.proc 
Sql :: plus or add balance in postgresql sql 
Sql :: sql select query 
Sql :: mysql replication change database name 
Sql :: connect colab with Microsoft sql server 
Sql :: sql fetch next 10 rows pdo 
Sql :: SQL IN Operator With Duplicate Values 
Sql :: java check if something is in mysql table 
Sql :: except in sql alchemy 
Sql :: mysql grant execute 
Sql :: what is constraints in dbms 
Sql :: tsql select everything before a character 
Sql :: mysql export data with a where clause 
Sql :: amount to words oracle Function 
Sql :: mysql if without else 
Sql :: sql server convert string list integers list 
Sql :: mysql load data infile default file location 
Sql :: bus source and destination equal to destination and source of another by sql query 
Sql :: faster mysql imports 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =