pinger_bot.models#

DB models for the project.

Module Contents#

Classes#

Server

A server model. Used to store the server, that was added to bot.

Ping

Represents a single ping record in DB.

Database

Some cached info about database.

Attributes#

Base

Base object for all models.

db

Initialized Database object.

Base[source]#

Base object for all models.

class Server[source]#

Bases: Base

A server model. Used to store the server, that was added to bot.

__tablename__ = pb_servers[source]#
id: int[source]#

Unique ID of the server, primary key.

host: str[source]#

Hostname of the server, can be number IP or domain. Always without port.

port: int[source]#

Port of the server.

max: int[source]#

Max players on the server.

alias: str | None[source]#

Alias of the server. Can be used as IP of the server.

owner: int[source]#

Owner’s Discord ID of the server.

__table_args__ = ()[source]#

Unique constraint for host and port.

class Ping[source]#

Bases: Base

Represents a single ping record in DB.

__tablename__ = pb_pings[source]#
id: int[source]#

Unique ID of the ping, primary key.

host: str[source]#

Host of the server, for which ping was made. This is a foreign key constraint.

port: int[source]#

Port of the server, for which ping was made. This is a foreign key constraint.

time: datetime.datetime[source]#

Time of the ping. Default to current time.

players: int[source]#

Players online in moment of the ping.

__mapper_args__[source]#

Some magic to make eager loading work.

__table_args__ = ()[source]#

Define Foreign Key Constraint to associate pb_pings.host and pb_pings.port to pb_pings.host and pb_pings.port.

class Database[source]#

Some cached info about database.

engine() sqlalchemy.ext.asyncio.AsyncEngine[source]#

Async engine of the Database.

session() Callable[[], AsyncContextManager[sqlalchemy.ext.asyncio.AsyncSession]][source]#

Async session of the Database.

db[source]#

Initialized Database object.