19 lines
509 B
Python
19 lines
509 B
Python
from .app import SessionLocal, engine
|
|
from .models import Base, Author, Book
|
|
|
|
def run():
|
|
Base.metadata.create_all(engine)
|
|
s = SessionLocal()
|
|
a1 = Author(name="Ursula K. Le Guin")
|
|
a2 = Author(name="Octavia E. Butler")
|
|
s.add_all([
|
|
a1, a2,
|
|
Book(title="The Left Hand of Darkness", author=a1),
|
|
Book(title="A Wizard of Earthsea", author=a1),
|
|
Book(title="Parable of the Sower", author=a2),
|
|
])
|
|
s.commit()
|
|
s.close()
|
|
|
|
if __name__ == "__main__":
|
|
run()
|