models module
- class models.ApiUsage(url, response)
Bases:
sqlalchemy.orm.decl_api.Model
- datetime
- id
- speed
- status
- url
- class models.ExternalCalendar(code, name, url, description, user, approved=False)
Bases:
sqlalchemy.orm.decl_api.Model
- approved
- code
- description
- id
- name
- update_url(url)
- url
- user_id
- class models.GUID(*args, **kwargs)
Bases:
sqlalchemy.sql.type_api.TypeDecorator
Platform-independent GUID type.
Uses PostgreSQL’s UUID type, otherwise uses CHAR(32), storing as stringified hex values.
- impl
alias of
sqlalchemy.sql.sqltypes.CHAR
- load_dialect_impl(dialect)
Return a
TypeEngine
object corresponding to a dialect.This is an end-user override hook that can be used to provide differing types depending on the given dialect. It is used by the
TypeDecorator
implementation oftype_engine()
to help determine what type should ultimately be returned for a givenTypeDecorator
.By default returns
self.impl
.
- process_bind_param(value: Union[None, uuid.UUID, str], dialect) Union[None, str]
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngine
object, and from there to the DBAPIexecute()
method.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
This operation should be designed with the reverse operation in mind, which would be the process_result_value method of this class.
- Parameters
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None
.dialect – the
Dialect
in use.
- process_result_value(value, dialect)
Receive a result-row column value to be converted.
Subclasses should implement this method to operate on data fetched from the database.
Subclasses override this method to return the value that should be passed back to the application, given a value that is already processed by the underlying
TypeEngine
object, originally from the DBAPI cursor methodfetchone()
or similar.The operation could be anything desired to perform custom behavior, such as transforming or serializing data. This could also be used as a hook for validating logic.
- Parameters
value – Data to operate upon, of any type expected by this method in the subclass. Can be
None
.dialect – the
Dialect
in use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- exception models.LevelAccessDenied
Bases:
Exception
- class models.Link(schedule)
Bases:
sqlalchemy.orm.decl_api.Model
- choice
- id
- link
- schedule
- schedule_id
- class models.OldUser(**kwargs)
Bases:
backend.mixins.UserMixin
,sqlalchemy.orm.decl_api.Model
- autosave
- confirmed_at
- email
- classmethod get_emails()
- id
- property is_active
- last_schedule_id
- password
- schedules
- class models.Schedule(data, user=None)
Bases:
sqlalchemy.orm.decl_api.Model
Table used to store Schedules in the database.
- data
- get_link()
- id
- last_modified_by
- link
- old_users
- update_data(data)
Warning: the address of data must be different that of self.data For example: >>> data = schedule.data >>> data.label = “new_label” >>> schedule.update(data) … does not work ! Instead, do: >>> data = copy(schedule.data) >>> data.label = “new_label” >>> schedule.update(data) For more information, see: https://docs.sqlalchemy.org/en/13/orm/extensions/mutable.html
- update_label(label)
- update_last_modified_by(uuid)
- users
- exception models.ScheduleDoNotMatchError(database_id, data_id)
Bases:
Exception
Exception that will occur if a user tries to update a schedule’s data with a non-matching ID.
- class models.Usage(data)
Bases:
sqlalchemy.orm.decl_api.Model
- blueprint
- datetime
- endpoint
- id
- path
- remote_addr
- speed
- status
- track_var
- truncate_string(key, value)
- ua_browser
- ua_language
- ua_platform
- ua_version
- url
- url_args
- username
- view_args
- class models.User(**kwargs)
Bases:
backend.mixins.UserMixin
,sqlalchemy.orm.decl_api.Model
- add_schedule(schedule, level=0)
- autosave
- created_at
- email
- fgs
- first_name
- classmethod get_emails()
- get_id()
Returns the user’s identification attribute
- get_schedule(id)
Return the schedule in this user’s schedule list matching the given ID. None if no match is found.
- get_schedules()
Equivalent to User.schedules, but sorts the schedules according to their IDs to ensure similar behavior throughout the SQL databases.
- id
- last_name
- last_schedule_id
- last_seen_at
- remove_schedule(schedule: models.Schedule)
Removes a schedule from the schedules list. If user owns this schedule, deletes the schedule for all users.
- Parameters
schedule – the schedule
- roles
- schedules
- set_autosave(autosave)
- set_last_schedule_id(schedule_id)
- models.query_to_dataframe(query: flask_sqlalchemy.BaseQuery, *args: Any, **kwargs: Any) pandas.core.frame.DataFrame
Parses a SQL query from the database into a dataframe.
- Parameters
query (BaseQuery) – the query to be read
args (Any) – positional arguments to be passed to
pandas.read_sql()
kwargs (Any) – keyword arguments to be passed to
pandas.read_sql()
- Returns
a dataframe of table
- Return type
pd.DataFrame
- models.reformat_status_in_dataframe(df: pandas.core.frame.DataFrame)
Modifies in-place a dataframe in order to replace status (int) to status (str) with format 2XX, 4XX, 5XX, etc.
- Parameters
df (pd.DataFrame) – the dataframe containing a status column
- models.table_to_dataframe(table: sqlalchemy.orm.decl_api.Model, *args: Any, **kwargs: Any) pandas.core.frame.DataFrame
Parses a table from the database into a dataframe.
- Parameters
table (db.Model) – the table to be parsed
args (Any) – positional arguments to be passed to
pandas.read_sql()
kwargs (Any) – keyword arguments to be passed to
pandas.read_sql()
- Returns
a dataframe of table
- Return type
pd.DataFrame