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:
ModelModel representing a Y2K mini-homepage guestbook entry.
Stores guestbook data in a Cyworld-style format. Each entry contains an author, content, and creation timestamp.
- 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 overridingquery_class.Warning
The query interface is considered legacy in SQLAlchemy. Prefer using
session.execute(select())instead.