models module#
- class models.ApiUsage(url, response)[source]#
Bases:
sqlalchemy.orm.decl_api.Model- datetime#
- id#
- speed#
- status#
- url#
- class models.ExternalCalendar(code, name, url, description, user, approved=False)[source]#
Bases:
sqlalchemy.orm.decl_api.Model- approved#
- code#
- description#
- id#
- name#
- url#
- user_id#
- class models.GUID(*args, **kwargs)[source]#
Bases:
sqlalchemy.sql.type_api.TypeDecoratorPlatform-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)[source]#
Return a
TypeEngineobject 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
TypeDecoratorimplementation 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][source]#
Receive a bound parameter value to be converted.
Subclasses override this method to return the value that should be passed along to the underlying
TypeEngineobject, 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
Dialectin use.
- process_result_value(value, dialect)[source]#
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
TypeEngineobject, 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
Dialectin use.
This operation should be designed to be reversible by the “process_bind_param” method of this class.
- class models.Link(schedule)[source]#
Bases:
sqlalchemy.orm.decl_api.Model- choice#
- id#
- link#
- schedule#
- schedule_id#
- class models.OldUser(**kwargs)[source]#
Bases:
backend.mixins.UserMixin,sqlalchemy.orm.decl_api.Model- autosave#
- confirmed_at#
- email#
- id#
- property is_active#
- last_schedule_id#
- password#
- schedules#
- class models.Role(**kwargs)[source]#
Bases:
sqlalchemy.orm.decl_api.Model- description#
- id#
- name#
- users#
- class models.Schedule(data, user=None)[source]#
Bases:
sqlalchemy.orm.decl_api.ModelTable used to store Schedules in the database.
- data#
- id#
- last_modified_by#
- link#
- old_users#
- update_data(data)[source]#
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
- users#
- exception models.ScheduleDoNotMatchError(database_id, data_id)[source]#
Bases:
ExceptionException that will occur if a user tries to update a schedule’s data with a non-matching ID.
- class models.Usage(data)[source]#
Bases:
sqlalchemy.orm.decl_api.Model- blueprint#
- datetime#
- endpoint#
- id#
- path#
- remote_addr#
- speed#
- status#
- track_var#
- ua_browser#
- ua_language#
- ua_platform#
- ua_version#
- url#
- url_args#
- username#
- view_args#
- class models.User(**kwargs)[source]#
Bases:
backend.mixins.UserMixin,sqlalchemy.orm.decl_api.Model- autosave#
- created_at#
- email#
- fgs#
- first_name#
- get_schedule(id)[source]#
Return the schedule in this user’s schedule list matching the given ID. None if no match is found.
- get_schedules()[source]#
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)[source]#
Removes a schedule from the schedules list. If user owns this schedule, deletes the schedule for all users.
- Parameters
schedule – the schedule
- roles#
- schedules#
- models.query_to_dataframe(query: flask_sqlalchemy.BaseQuery, *args: Any, **kwargs: Any) pandas.core.frame.DataFrame[source]#
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)[source]#
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[source]#
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