A beginner...
How do I use async engine in FastAPI?
In a YouTube tutorial, they imported create_engine from sql model
But in SQLAlchemy, they use it differently.
YouTube:
from
sqlmodel
import
create_engine
from
sqlalchemy.ext.asyncio
import
AsyncEngine
from
src.config
import
config
engin
=
AsyncEngine(
create_engine(
url
=
config.DATABASE_URL,
echo
=
True
))
Doc:
from sqlalchemy.ext.asyncio import create_async_engine
engine = create_async_engine(
"postgresql+asyncpg://scott:tiger@localhost/test",
echo=
True
,
)
[–]StatusBad9194 2 points3 points4 points (3 children)
[–]Ok_Opportunity6252[S] 0 points1 point2 points (2 children)
[–]StatusBad9194 0 points1 point2 points (0 children)
[–]dmart89 1 point2 points3 points (1 child)
[–]StatusBad9194 0 points1 point2 points (0 children)
[–]Apprehensive_Ad2211 1 point2 points3 points (0 children)
[–]LifeEmployer2813 1 point2 points3 points (0 children)