app.models Module

Models module — Defines database models for the Y2K blog.

Uses Flask-SQLAlchemy to define the blog’s data schema. Currently provides the GuestbookEntry model; a Post model is planned for future releases.

app.models.db: SQLAlchemy = <SQLAlchemy>

SQLAlchemy database instance.

class app.models.GuestbookEntry(**kwargs)[source]

Bases: Model

Model representing a Y2K mini-homepage guestbook entry.

Stores guestbook data in a Cyworld-style format. Each entry contains an author, content, and creation timestamp.

id

Unique identifier (Primary Key, Auto Increment).

Type:

int

author

Name of the guestbook author. Max 50 characters, required field.

Type:

str

content

Guestbook message content. Max 500 characters, required field.

Type:

str

created_at

Timestamp of creation. Defaults to datetime.utcnow.

Type:

datetime

Example

>>> entry = GuestbookEntry(author="Neo", content="Follow the white rabbit")
>>> db.session.add(entry)
>>> db.session.commit()
id
author
content
created_at
query: t.ClassVar[Query]

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.