SQL Storage Adapter

class chatterbot.storage.SQLStorageAdapter(**kwargs)[source]

The SQLStorageAdapter allows ChatterBot to store conversation data in any database supported by the SQL Alchemy ORM.

All parameters are optional, by default a sqlite database is used.

It will check if tables are present, if they are not, it will attempt to create the required tables.

Parameters:

database_uri (str) – eg: sqlite:///database_test.sqlite3’, The database_uri can be specified to choose database driver.

count()[source]

Return the number of entries in the database.

create(text, in_response_to=None, tags=None, search_text=None, search_in_response_to=None, **kwargs)[source]

Creates a new statement matching the keyword arguments specified. Returns the created statement.

create_database()[source]

Populate the database with the tables.

create_many(statements)[source]

Creates multiple statement entries.

drop()[source]

Drop the database.

filter(**kwargs)[source]

Returns a list of objects from the database. The kwargs parameter can contain any number of attributes. Only objects which contain all listed attributes and in which all values match for all listed attributes will be returned.

get_random()[source]

Returns a random statement from the database.

get_statement_model()[source]

Return the statement model.

get_tag_model()[source]

Return the conversation model.

remove(statement_text)[source]

Removes the statement that matches the input text. Removes any responses from statements where the response text matches the input text.

update(statement)[source]

Modifies an entry in the database. Creates an entry if one does not exist.