Created
October 21, 2022 10:36
-
-
Save Glukhoff/12b33bf4bccb00a73ea735e09dbbb781 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession | |
from sqlalchemy.orm import sessionmaker, declarative_base | |
Base = declarative_base() | |
def create_poll(user: str, password: str, host: str, name: str) -> sessionmaker: | |
engine = create_async_engine( | |
f"postgresql+asyncpg://{user}:{password}@{host}/{name}", | |
future=True | |
) | |
return sessionmaker(engine, expire_on_commit=False, class_=AsyncSession) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment