db

In this module there are all the database setups and models used by the WeatherDB package, you shouldn’t need to use them directly.

models

Those are the database models

class weatherdb.db.models.MetaP(**kwargs)[source]

Bases: MetaBase, MetaBaseQC

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

last_imp_corr: Mapped[bool]
corr_from: Mapped[UTCDateTime | None]
corr_until: Mapped[UTCDateTime | None]
horizon: Mapped[float | None]
richter_class: Mapped[str | None]
bundesland: Mapped[str30]
filled_from: Mapped[UTCDateTime | None]
filled_until: Mapped[UTCDateTime | None]
geometry: Mapped[str]
geometry_utm: Mapped[str]
hist_until: Mapped[UTCDateTime | None]
is_real: Mapped[bool]
last_imp_filled: Mapped[bool]
last_imp_from: Mapped[UTCDateTime | None]
last_imp_qc: Mapped[bool]
last_imp_until: Mapped[UTCDateTime | None]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

qc_dropped: Mapped[float | None]
qc_from: Mapped[UTCDateTime | None]
qc_until: Mapped[UTCDateTime | None]
raw_from: Mapped[UTCDateTime | None]
raw_until: Mapped[UTCDateTime | None]
registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

station_id: Mapped[int]
stationshoehe: Mapped[int]
stationsname: Mapped[str50]
class weatherdb.db.models.MetaPD(**kwargs)[source]

Bases: MetaBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

bundesland: Mapped[str30]
filled_from: Mapped[UTCDateTime | None]
filled_until: Mapped[UTCDateTime | None]
geometry: Mapped[str]
geometry_utm: Mapped[str]
hist_until: Mapped[UTCDateTime | None]
is_real: Mapped[bool]
last_imp_filled: Mapped[bool]
last_imp_from: Mapped[UTCDateTime | None]
last_imp_until: Mapped[UTCDateTime | None]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

raw_from: Mapped[UTCDateTime | None]
raw_until: Mapped[UTCDateTime | None]
registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

station_id: Mapped[int]
stationshoehe: Mapped[int]
stationsname: Mapped[str50]
class weatherdb.db.models.MetaET(**kwargs)[source]

Bases: MetaBase, MetaBaseQC

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

bundesland: Mapped[str30]
filled_from: Mapped[UTCDateTime | None]
filled_until: Mapped[UTCDateTime | None]
geometry: Mapped[str]
geometry_utm: Mapped[str]
hist_until: Mapped[UTCDateTime | None]
is_real: Mapped[bool]
last_imp_filled: Mapped[bool]
last_imp_from: Mapped[UTCDateTime | None]
last_imp_qc: Mapped[bool]
last_imp_until: Mapped[UTCDateTime | None]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

qc_dropped: Mapped[float | None]
qc_from: Mapped[UTCDateTime | None]
qc_until: Mapped[UTCDateTime | None]
raw_from: Mapped[UTCDateTime | None]
raw_until: Mapped[UTCDateTime | None]
registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

station_id: Mapped[int]
stationshoehe: Mapped[int]
stationsname: Mapped[str50]
class weatherdb.db.models.MetaT(**kwargs)[source]

Bases: MetaBase, MetaBaseQC

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

bundesland: Mapped[str30]
filled_from: Mapped[UTCDateTime | None]
filled_until: Mapped[UTCDateTime | None]
geometry: Mapped[str]
geometry_utm: Mapped[str]
hist_until: Mapped[UTCDateTime | None]
is_real: Mapped[bool]
last_imp_filled: Mapped[bool]
last_imp_from: Mapped[UTCDateTime | None]
last_imp_qc: Mapped[bool]
last_imp_until: Mapped[UTCDateTime | None]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

qc_dropped: Mapped[float | None]
qc_from: Mapped[UTCDateTime | None]
qc_until: Mapped[UTCDateTime | None]
raw_from: Mapped[UTCDateTime | None]
raw_until: Mapped[UTCDateTime | None]
registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

station_id: Mapped[int]
stationshoehe: Mapped[int]
stationsname: Mapped[str50]
class weatherdb.db.models.RawFiles(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

parameter: Mapped[Annotated[str, 3]]
filepath: Mapped[str]
modtime: Mapped[UTCDateTime]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.DroppedStations(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

station_id: Mapped[int]
parameter: Mapped[Annotated[str, 3]]
why: Mapped[str]
timestamp: Mapped[UTCDateTime]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.ParameterVariables(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

parameter: Mapped[Annotated[str, 3]]
start_tstp_last_imp: Mapped[UTCDateTime | None]
max_tstp_last_imp: Mapped[UTCDateTime | None]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.StationMATimeserie(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

station_id: Mapped[int]
parameter: Mapped[Annotated[str, 3]]
kind: Mapped[str]
value: Mapped[int]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.StationMARaster(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

station_id: Mapped[int]
raster_key: Mapped[Annotated[str, 7]]
parameter: Mapped[Annotated[str, 3]]
term: Mapped[Annotated[str, 4]]
value: Mapped[int]
distance: Mapped[int]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.NeededDownloadTime(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

timestamp: Mapped[UTCDateTime]
quantity: Mapped[int]
aggregate: Mapped[str]
timespan: Mapped[timedelta]
zip: Mapped[bool]
pc: Mapped[str]
duration: Mapped[timedelta]
output_size: Mapped[int]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.Settings(**kwargs)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

key: Mapped[str]
value: Mapped[str]
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

base models

class weatherdb.db.models.ModelBase(**kwargs: Any)[source]

Bases: DeclarativeBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

class weatherdb.db.models.MetaBase(**kwargs: Any)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

station_id: Mapped[int] = <sqlalchemy.orm.properties.MappedColumn object>
is_real: Mapped[bool] = <sqlalchemy.orm.properties.MappedColumn object>
stationsname: Mapped[Annotated[str, 50]] = <sqlalchemy.orm.properties.MappedColumn object>
bundesland: Mapped[Annotated[str, 30]] = <sqlalchemy.orm.properties.MappedColumn object>
raw_from: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
raw_until: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
hist_until: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
last_imp_from: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
last_imp_until: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
last_imp_filled: Mapped[bool] = <sqlalchemy.orm.properties.MappedColumn object>
filled_from: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
filled_until: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
stationshoehe: Mapped[int] = <sqlalchemy.orm.properties.MappedColumn object>
geometry: Mapped[str] = <sqlalchemy.orm.properties.MappedColumn object>
geometry_utm: Mapped[str] = <sqlalchemy.orm.properties.MappedColumn object>
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.models.MetaBaseQC(**kwargs: Any)[source]

Bases: ModelBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

last_imp_qc: Mapped[bool] = <sqlalchemy.orm.properties.MappedColumn object>
qc_from: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
qc_until: Mapped[UTCDateTime | None] = <sqlalchemy.orm.properties.MappedColumn object>
qc_dropped: Mapped[float | None] = <sqlalchemy.orm.properties.MappedColumn object>
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

views

Those are the database views

class weatherdb.db.views.StationMATimeserieRasterQuotientView(**kwargs)[source]

Bases: ViewBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

station_id: Mapped[int]
parameter: Mapped[str]
kind: Mapped[str]
raster_key: Mapped[str]
value: Mapped[float]
classmethod create_view(target, connection, **kwargs)
classmethod drop_view(target, connection, **kwargs)
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

class weatherdb.db.views.StationKindQuotientView(**kwargs)[source]

Bases: ViewBase

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

station_id: Mapped[int]
parameter: Mapped[str]
kind_numerator: Mapped[str]
kind_denominator: Mapped[str]
value: Mapped[float]
classmethod create_view(target, connection, **kwargs)
classmethod drop_view(target, connection, **kwargs)
metadata: ClassVar[MetaData] = MetaData()

Refers to the _schema.MetaData collection that will be used for new _schema.Table objects.

registry: ClassVar[_RegistryType] = <sqlalchemy.orm.decl_api.registry object>

Refers to the _orm.registry in use where new _orm.Mapper objects will be associated.

smt1 = <AliasedClass at 0x7512ac0efaf0; StationMATimeserie>
smt2 = <AliasedClass at 0x7512ac0ed870; StationMATimeserie>

connections

class weatherdb.db.connections.DBEngine[source]

Bases: object

connect(*args, **kwargs)[source]
get_engine()[source]

Get the sqlalchemy database engine.

Returns the last created engine if possible or creates a new one.

Returns:

_description_

Return type:

sqlalchemy.engine.base.Engine

create_engine()[source]
property engine
create_session()[source]

Create a new session from the engine.

Returns:

_description_

Return type:

sqlalchemy.orm.session.Session

get_session()[source]

Get a session from the engine.

Returns:

_description_

Return type:

sqlalchemy.orm.session.Session

property session
reload_config()[source]

Reload the configuration and create a new engine.

property is_superuser
property select_privilege

Does the user have the PostGreSQL SELECT privilege on the database?

property update_privilege

Does the user have the PostGreSQL UPDATE privilege on the database?

property insert_privilege

Does the user have the PostGreSQL INSERT privilege on the database?

property upsert_privilege

Does the user have the PostGreSQL INSERT and UPDATE privilege on the database?

property create_privilege

Does the user have the PostGreSQL CREATE privilege on the database?

property delete_privilege

Does the user have the PostGreSQL DELETE privilege on the database?

property all_privileges

Does the user have all (SELECT, UPDATE, INSERT, DELETE, CREATE) PostGreSQL privileges on the database?

deco_is_superuser(target)[source]

Decorator to check if the user is a superuser.

deco_select_privilege(target)[source]

Decorator to check if the user has the SELECT privilege.

deco_update_privilege(target)[source]

Decorator to check if the user has the UPDATE privilege.

deco_insert_privilege(target)[source]

Decorator to check if the user has the INSERT privilege.

deco_upsert_privilege(target)[source]

Decorator to check if the user has the INSERT and UPDATE privilege.

deco_create_privilege(target)[source]

Decorator to check if the user has the CREATE privilege.

deco_delete_privilege(target)[source]

Decorator to check if the user has the DELETE privilege.

deco_all_privileges(target)[source]

Decorator to check if the user has all (SELECT, UPDATE, INSERT, DELETE, CREATE) privileges.