frost.server.database package

Submodules

frost.server.database.db module

class frost.server.database.db.Base(**kwargs)

Bases: object

The most base type

metadata = MetaData(bind=None)
frost.server.database.db.engine = Engine(sqlite:///pyfrost.sqlite3)

The SQLAlchemy engine.

frost.server.database.db.init_db() → None

Initlializes a database and creates the pre-defined models.

frost.server.database.db.managed_session() → Session

A context manager for thread-safe database access. Automatically commits if no errors occur, else it is rolled back. Session is removed after use.

Yield

An SQLAlchemy scoped_session

Return type

sqlalchemy.orm.Session

frost.server.database.models module

class frost.server.database.models.Message(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

The Message model. __tablename__ = 'messages'

id

The message’s ID.

message

The message’s contents.

room

The room the message was sent in.

room_id

The ID of the room the message was sent in.

timestamp

The date and time the message was sent.

user

The user who sent the message.

user_id

The ID of the user who sent the message.

class frost.server.database.models.Room(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

The Room model. __tablename__ = 'rooms'

id

The room’s ID.

invite_code

The room’s invite code.

messages

The messages that have been sent in the room.

name

The room’s name.

owner_id

The ID of the user who created the room.

users

The users who are have joined the room.

class frost.server.database.models.User(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

The User model. __tablename__ = 'users'

id

The user’s ID.

joined_rooms

The different rooms the user has joined.

messages

The messages the user has sent.

password

The user’s password.

token

The user’s authentication token, used after login.

username

The user’s username.

frost.server.database.models.user_room_association = Table('user_room_association', MetaData(bind=None), Column('users', Integer(), ForeignKey('users.id'), table=<user_room_association>), Column('rooms', Integer(), ForeignKey('rooms.id'), table=<user_room_association>), schema=None)

An association from the many-to-many relationship between users and rooms.

Module contents

frost.server.database.init_db() → None

Initlializes a database and creates the pre-defined models.

frost.server.database.managed_session() → Session

A context manager for thread-safe database access. Automatically commits if no errors occur, else it is rolled back. Session is removed after use.

Yield

An SQLAlchemy scoped_session

Return type

sqlalchemy.orm.Session

class frost.server.database.Base(**kwargs)

Bases: object

The most base type

metadata = MetaData(bind=None)
class frost.server.database.User(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

The User model. __tablename__ = 'users'

id

The user’s ID.

joined_rooms

The different rooms the user has joined.

messages

The messages the user has sent.

password

The user’s password.

token

The user’s authentication token, used after login.

username

The user’s username.

class frost.server.database.Room(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

The Room model. __tablename__ = 'rooms'

id

The room’s ID.

invite_code

The room’s invite code.

messages

The messages that have been sent in the room.

name

The room’s name.

owner_id

The ID of the user who created the room.

users

The users who are have joined the room.

class frost.server.database.Message(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

The Message model. __tablename__ = 'messages'

id

The message’s ID.

message

The message’s contents.

room

The room the message was sent in.

room_id

The ID of the room the message was sent in.

timestamp

The date and time the message was sent.

user

The user who sent the message.

user_id

The ID of the user who sent the message.