Website.add_user_database_using_sql#
- Website.add_user_database_using_sql(database_uri, other_columns=[], user_cls=None, table_name='users')#
Creates a simple database that has data specific to each user.
The database has a table that contains the following columns: username, password, and id. To add other columns, add their names in other_columns list. Note that this is different from user_vars which is a stores temporary data without the need to sign in.
Warning
A table called users (or whatever you input as table_name) will be created in the database. If you already have a table with the same name, it might be overwritten.
- 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, email and id.
user_cls (Callable, default=None) – If this parameter is
None, a table called users will be created. However, if this parameter was set, the table users will not be created and the parameter user_cls will be used instead.table_name (str, default="users") – The name of the table that will be created/modified in the database.
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