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
import os | |
import warnings | |
from contextvars import ContextVar | |
from typing import AsyncGenerator | |
from unittest import mock | |
import alembic | |
import pytest | |
from alembic.config import Config |
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
""" | |
This is a helper module to deal with datetime and timezones. | |
For convenience datetime related modules (e.g. dateutil.parser, pytz, etc) are | |
imported here so they can be accessed using this module. | |
Usage: | |
>>> from fastapi_sqlalchemy import tz | |
>>> dt1 = tz.utcnow() | |
>>> dt2 = tz.utcdatetime(2015, 1, 2, 1, 2, 3) | |
>>> dt2 = dt2.astimezone(tz.LOCAL) | |
>>> dt2 = dt2.astimezone(tz.UTC) |
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.orm import sessionmaker | |
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine # noqa | |
engine = create_async_engine("") | |
SessionLocal = sessionmaker( | |
class_=AsyncSession, | |
autocommit=False, | |
autoflush=False, | |
bind=engine |