28 lines
804 B
Python
28 lines
804 B
Python
from sqlalchemy import ForeignKey, String, Table, Column, Integer, MetaData, Date
|
|
|
|
# NOTE: MetaData object - object where we place out tables
|
|
# Essentialy - this is a facade around Python dicts, that stores series of Table objects keyed to their string name
|
|
metadata_obj = MetaData()
|
|
|
|
# Representation of training table
|
|
training = Table(
|
|
"training",
|
|
metadata_obj,
|
|
Column("ID", Integer, primary_key=True),
|
|
Column("DATE", Date),
|
|
)
|
|
|
|
# Representation of exercise table
|
|
exercise = Table(
|
|
"exercise",
|
|
metadata_obj,
|
|
Column("ID", Integer, primary_key=True),
|
|
Column("TRAINING", ForeignKey("training.ID"), nullable=False),
|
|
Column("NAME", String(256)),
|
|
)
|
|
|
|
|
|
# NOTE: We can access table metadata with associative array `c`
|
|
# print(training.c.keys())
|
|
# print(training.primary_key)
|
|
|