royalnet.database¶
Relational database classes and methods.
-
class
royalnet.database.
Alchemy
(database_uri: str, tables: Set[T])¶ 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[T])¶ Create a new Alchemy object.
- Parameters
database_uri – The uri of the database, as described at https://docs.sqlalchemy.org/en/13/core/engines.html .
tables – The set of tables to be created and used in the selected database. Check the tables submodule for more details.
-
_create_tables
(tables: Set[T])¶
-
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[CT_co], identity_table: Type[CT_co], 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 0x7f63c90; 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 0x7f63810; 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 0x7f73270; 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 0x7f637c8; no key>¶
-
royal_id
= Column(None, Integer(), ForeignKey('royals.uid'), table=None)¶
-
-
class
royalnet.database.tables.
ActiveKvGroup
¶ -
group
= <RelationshipProperty at 0x7f63978; no key>¶
-
group_name
= Column(None, String(), ForeignKey('keygroups.group_name'), table=None, nullable=False)¶
-
royal
= <RelationshipProperty at 0x7f63660; 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 0x7f63fa8; 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 0x7f63e40; 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!
-
content
= 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)¶
-
page_short_id
¶
-
title
= Column(None, String(), table=None, nullable=False)¶
-
-
class
royalnet.database.tables.
WikiRevision
¶ A wiki page revision.
Warning
Requires PostgreSQL!
-
diff
= Column(None, Text(), table=None)¶
-
page
= <RelationshipProperty at 0x7f732b8; 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)¶
-