From 5e44093e2d9129865fc1aef3c56911b4d22123cf Mon Sep 17 00:00:00 2001 From: collerek Date: Mon, 26 Oct 2020 10:09:10 +0100 Subject: [PATCH] update docs for db init and migrations --- docs/fastapi.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/fastapi.md b/docs/fastapi.md index 6078053..6cae18a 100644 --- a/docs/fastapi.md +++ b/docs/fastapi.md @@ -59,6 +59,17 @@ as `response_model` and as a requests parameters. Here you have a sample test that will prove that everything works as intended. +Be sure to create the tables first. If you are using pytest you can use a fixture. + +```python +@pytest.fixture(autouse=True, scope="module") +def create_test_database(): + engine = sqlalchemy.create_engine(DATABASE_URL) + metadata.create_all(engine) + yield + metadata.drop_all(engine) +``` + ```python # here is a sample test to check the working of the ormar with fastapi