flexget.db_schema module#

exception flexget.db_schema.UpgradeImpossible[source]#

Bases: Exception

Exception to be thrown during a db upgrade function which will cause the old tables to be removed and recreated from the new model.

class flexget.db_schema.FlexgetVersion[source]#

Bases: Base

_sa_class_manager = {'created': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'version': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
created#
version#
class flexget.db_schema.PluginSchema(plugin, version=0)[source]#

Bases: Base

_sa_class_manager = {'id': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'plugin': <sqlalchemy.orm.attributes.InstrumentedAttribute object>, 'version': <sqlalchemy.orm.attributes.InstrumentedAttribute object>}#
id#
plugin#
version#
class flexget.db_schema.VersionedBaseMeta(metaname, bases, dict_)[source]#

Bases: DeclarativeMeta

Metaclass for objects returned by versioned_base factory.

register_table(table)[source]#

Can be used if a plugin is declaring non-declarative sqlalchemy tables.

Parameters:

table (str | Table) – Can either be the name of the table, or an sqlalchemy.Table instance.

Return type:

None

flexget.db_schema.after_table_create(target, connection, tables=None, **kw)[source]#

Set the schema version to most recent for a plugin when it’s tables are freshly created.

Parameters:

tables (list[Table] | None)

Return type:

None

flexget.db_schema.get_flexget_db_version()[source]#
Return type:

str | None

flexget.db_schema.register_plugin_table(tablename, plugin, version)[source]#
Parameters:
flexget.db_schema.set_flexget_db_version(manager=None)[source]#
Return type:

None

flexget.db_schema.upgrade(plugin)[source]#

Use as a decorator to register a schema upgrade function.

The wrapped function will be passed the current schema version and a session object. The function should return the new version of the schema after the upgrade.

There is no need to commit the session, it will commit automatically if an upgraded schema version is returned.

Example:

from flexget import schema


@schema.upgrade('your_plugin')
def upgrade(ver, session):
    if ver == 2:
        # upgrade
        ver = 3
    return ver
Parameters:

plugin (str)

Return type:

Callable

flexget.db_schema.versioned_base(plugin, version)[source]#

Return a class which can be used like Base, but automatically stores schema version when tables are created.

Parameters:
Return type:

VersionedBaseMeta