grillazz / fastapi-sqlalchemy-asyncpg Goto Github PK
View Code? Open in Web Editor NEWIntegration of FastAPI framework supported by Pydantic with SQLAlchemy ORM and PostgreSQL on asyncpg driver
License: MIT License
Integration of FastAPI framework supported by Pydantic with SQLAlchemy ORM and PostgreSQL on asyncpg driver
License: MIT License
I've come across your project and I really appreciate what you've done.
I have a question that bugs me for a long time and I've never seen any project addressing it, including yours.
When you create an AsyncEngine
, you are supposed to dispose it, ideally in shutdown
event. However, I never see anyone doing it in practice. Is it because you rely on GC of Python to clean it for you?
Hey,
I'm using your boilerplate to setup my fastapi with sqlalchemy and asyncpg.
Now when I do some load testing on my API, after a few concurrent requests , I have the following issue:
asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress
How can I prevent this ?
Thanks,
Henry
add initial dataset to feed database tables
https://rich.readthedocs.io/en/stable/logging.html
implementation samples
https://github.com/nsidnev/fastapi-realworld-example-app/blob/master/app/core/logging.py
example log.ini
https://github.com/RedHatInsights/policies-notifications/blob/master/logging.ini
additional reading
options are: mypy, pyright, pyre
Try to debug this app and have problem https://stackoverflow.com/questions/53127794/importerror-cannot-import-name-getlogger
Please, rename logging.py
expose key, value as property and test response with pydantic
add docker-slim as optional use case
Hey grillazz! Thanks for this awesome repo :)
Does this method have any purpose? It does not seem to be referenced anywhere.
fastapi-sqlalchemy-asyncpg/app/database.py
Lines 36 to 50 in e71d41a
import os
from functools import lru_cache
from pydantic import PostgresDsn, RedisDsn
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
asyncpg_url: PostgresDsn = os.getenv("SQL_URL")
secret_key: str = os.getenv("FERNET_KEY")
redis_url: RedisDsn = os.getenv("REDIS_URL")
jwt_algorithm: str = os.getenv("JWT_ALGORITHM")
jwt_expire: int = os.getenv("JWT_EXPIRE")
@lru_cache
def get_settings():
return Settings()
settings = get_settings()
It's the same as below, I think. Because get_setting() with @lru_cache will always return the same object.:
import os
from functools import lru_cache
from pydantic import PostgresDsn, RedisDsn
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
asyncpg_url: PostgresDsn = os.getenv("SQL_URL")
secret_key: str = os.getenv("FERNET_KEY")
redis_url: RedisDsn = os.getenv("REDIS_URL")
jwt_algorithm: str = os.getenv("JWT_ALGORITHM")
jwt_expire: int = os.getenv("JWT_EXPIRE")
settings = Setting()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.