Nicer scripts and directive foor databases

This commit is contained in:
Colin Goutte 2023-08-26 17:20:54 +02:00
parent df1dbbbc18
commit 8b8a1ed30a
2 changed files with 11 additions and 4 deletions

View File

@ -45,7 +45,11 @@ venv_test:
make -f MakefileVenv test
db_clean:
rm sql_app.db
rm sql_app.db && touch sql_app.db
db_fill:
pipenv run python database.py
db_reset: db_clean db_fill

View File

@ -24,10 +24,13 @@ def fill_db():
import crud
import random
for _ in range(10):
def _genres():
random.choice([["Comedy"], ["Comedy", "Drama"], []])
for _ in range(3):
name = f"fill_db_{random.randint(1, 1000):03}"
out = crud.create_movie(SessionLocal(), name=name)
print(out.name)
out = crud.create_movie(SessionLocal(), title=name, genres=_genres())
print(out.title)
if __name__ == "__main__":