royalnet.database

Relational database classes and methods.

class royalnet.database.Alchemy(database_uri: str, tables: Set)

A wrapper around SQLAlchemy declarative that allows to use multiple databases at once while maintaining a single table-class for both of them.

__init__(database_uri: str, tables: Set)

Create a new Alchemy object.

Parameters
_create_tables(tables: Set)
session_acm()

Use Alchemy as a asyncronous context manager (to be used in async with statements).

session_cm()

Use Alchemy as a context manager (to be used in with statements).

royalnet.database.relationshiplinkchain(starting_class, ending_class) → Optional[tuple]

Find the path to follow to get from the starting table to the ending table.

class royalnet.database.DatabaseConfig(database_uri: str, master_table: Type, identity_table: Type, identity_column_name: str)

The configuration to be used for the royalnet.database.Alchemy component of royalnet.bots.GenericBot.

Tables

class royalnet.database.tables.Royal
avatar = Column(None, LargeBinary(), table=None)
password = Column(None, LargeBinary(), table=None)
role = Column(None, String(), table=None, nullable=False)
uid = Column(None, Integer(), table=None, primary_key=True, nullable=False)
username = Column(None, String(), table=None, nullable=False)
class royalnet.database.tables.Telegram
first_name = Column(None, String(), table=None)
last_name = Column(None, String(), table=None)
mention() → str
royal = <RelationshipProperty at 0x77b4108; no key>
royal_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None)
tg_id = Column(None, BigInteger(), table=None, primary_key=True, nullable=False)
username = Column(None, String(), table=None)
class royalnet.database.tables.Diario
context = Column(None, Text(), table=None)
creator = <RelationshipProperty at 0x77b4348; no key>
creator_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None)
diario_id = Column(None, Integer(), table=None, primary_key=True, nullable=False)
media_url = Column(None, String(), table=None)
quoted = Column(None, String(), table=None)
quoted_account = <RelationshipProperty at 0x77b45d0; no key>
quoted_account_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None)
spoiler = Column(None, Boolean(), table=None, default=ColumnDefault(False))
text = Column(None, Text(), table=None)
timestamp = Column(None, DateTime(), table=None, nullable=False)
class royalnet.database.tables.Alias
alias = Column(None, String(), table=None, primary_key=True, nullable=False)
royal = <RelationshipProperty at 0x77b4300; no key>
royal_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None)
class royalnet.database.tables.ActiveKvGroup
group = <RelationshipProperty at 0x7733f18; no key>
group_name = Column(None, String(), ForeignKey('keygroups.group_name'), table=None, nullable=False)
royal = <RelationshipProperty at 0x77b4300; no key>
royal_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None, primary_key=True, nullable=False)
class royalnet.database.tables.Keyvalue
group = <RelationshipProperty at 0x77b4660; no key>
group_name = Column(None, String(), ForeignKey('keygroups.group_name'), table=None, primary_key=True, nullable=False)
key = Column(None, String(), table=None, primary_key=True, nullable=False)
value = Column(None, String(), table=None, nullable=False)
class royalnet.database.tables.Keygroup
group_name = Column(None, String(), ForeignKey('keygroups.group_name'), table=None, primary_key=True, nullable=False)
class royalnet.database.tables.Discord
avatar_hash = Column(None, String(), table=None)
discord_id = Column(None, BigInteger(), table=None, primary_key=True, nullable=False)
discriminator = Column(None, String(), table=None)
full_username()
royal = <RelationshipProperty at 0x77b45d0; no key>
royal_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None)
username = Column(None, String(), table=None)
class royalnet.database.tables.WikiPage

Wiki page properties.

Warning

Requires PostgreSQL!

contents = Column(None, Text(), table=None)
css = Column(None, String(), table=None)
format = Column(None, String(), table=None, nullable=False, default=ColumnDefault('markdown'))
page_id = Column(None, UUID(as_uuid=True), table=None, primary_key=True, nullable=False)
property page_short_id
title = Column(None, String(), table=None, nullable=False)
class royalnet.database.tables.WikiRevision

A wiki page revision.

Warning

Requires PostgreSQL!

author = <RelationshipProperty at 0x77b4738; no key>
author_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None, nullable=False)
diff = Column(None, Text(), table=None)
page = <RelationshipProperty at 0x77b4150; no key>
page_id = Column(None, UUID(as_uuid=True), ForeignKey('wikipages.page_id'), table=None, nullable=False)
reason = Column(None, Text(), table=None)
revision_id = Column(None, UUID(as_uuid=True), table=None, primary_key=True, nullable=False)
timestamp = Column(None, DateTime(), table=None, nullable=False)
class royalnet.database.tables.Medal
classes = Column(None, String(), table=None, nullable=False, default=ColumnDefault(''))
description = Column(None, String(), table=None)
icon = Column(None, String(), table=None)
mid = Column(None, Integer(), table=None, primary_key=True, nullable=False)
name = Column(None, String(), table=None, nullable=False)
score = Column(None, Integer(), table=None, nullable=False)
class royalnet.database.tables.MedalAward
award_id = Column(None, Integer(), table=None, primary_key=True, nullable=False)
date = Column(None, DateTime(), table=None)
medal = <RelationshipProperty at 0x77b4858; no key>
medal_id = Column(None, Integer(), ForeignKey('medals.mid'), table=None, nullable=False)
royal = <RelationshipProperty at 0x77b43d8; no key>
royal_id = Column(None, Integer(), ForeignKey('royal.uid'), table=None, nullable=False)
class royalnet.database.tables.Bio
contents = Column(None, Text(), table=None, nullable=False, default=ColumnDefault(''))
royal = <RelationshipProperty at 0x77b4300; no key>
royal_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None, primary_key=True, nullable=False)
class royalnet.database.tables.Reminder
creator = <RelationshipProperty at 0x77b4c00; no key>
creator_id = Column(None, Integer(), ForeignKey('royals.uid'), table=None)
datetime = Column(None, DateTime(), table=None)
interface_data = Column(None, LargeBinary(), table=None)
interface_name = Column(None, String(), table=None)
message = Column(None, String(), table=None)
reminder_id = Column(None, Integer(), table=None, primary_key=True, nullable=False)