Website.add_user_database#
- Website.add_user_database(database_uri, other_columns=[], user_cls=None)#
Creates a simple database that has data specific to each user.
The database is a table that contains the following columns: username, password, and id. To add other columns, add their names in other_columns list.
- Parameters:
database_uri (str) – The URI of the database that you want to connect to.
other_columns (list) – The names of table columns other than username, password, and id.
user_cls (Callable, default=None) – If this parameter is
None, a table called User will be created. However, if this parameter was set, the table User will not be created and the parameter user_cls will be used instead.
Behind The Scenes
The following flask extensions are used when calling this function:
SQLAlchemy class extension from Flask-SQLAlchemy package.
LoginManager class extension from Flask-Login package.
The following Flask configurations are also set:
SQLALCHEMY_DATABASE_URI = database_uri