Nicer scripts and directive foor databases
This commit is contained in:
parent
df1dbbbc18
commit
8b8a1ed30a
6
Makefile
6
Makefile
|
@ -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
|
||||
|
||||
|
|
|
@ -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__":
|
||||
|
|
Loading…
Reference in New Issue