from sqlalchemy import Float, 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)), ) approach = Table( "approach", metadata_obj, Column("Id", Integer, primary_key=True), Column("Exercise", ForeignKey("exercise.Id"), nullable=False), Column("Weight", Float), Column("Reps", Integer), ) # NOTE: We can access table metadata with associative array `c` # print(training.c.keys()) # print(training.primary_key) print(training.name)