Skip to content
Gabe edited this page Oct 19, 2024 · 2 revisions

1. What are tags in FastAPI?

I'm not sure yet. TODO: this!

2. What is an AsyncIterator in python?

See https://superfastpython.com/asynchronous-iterators/ . Effectively, it's just an iterator that awaits each iteration of a loop, so other tasks can be done in the meantime. A good example of this might be a chain of internet requests that need to be made, ex: fetch a.html -> fetch b.css -> fetch c.jpg.

3. What is the Depends(...) parameter in all the api endpoints?

see https://fastapi.tiangolo.com/tutorial/dependencies/

4. Why is response: Response in the parameters? Shouldn't it be returned in the object or something?

fastapi is silly sometimes, this is just how it is I guess...

5. Help python async/await is killing me

https://docs.python.org/3/library/asyncio-task.html#awaitables

Good luck my friend

6. Why is there a main database & a test database?

The test database is for use without worrying about alembic migrations, while the main database is for testing that alembic migrations worked properly.

To activate the main database, export LOCAL=false, otherwise if you want to enable the test database export LOCAL=true.

7. How do I UPDATE changes to the database in SQL alchemy?

See https://stackoverflow.com/questions/9667138/how-to-update-sqlalchemy-row-entry. Essentially, there are many ways! I encourage you to use the SQL-like method of:

query = (
    sqlalchemy
    .update()
    .values(no_of_logins=User.no_of_logins + 1)
    .where(User.username == form.username.data)
)