mirror of
https://github.com/evroon/bracket.git
synced 2026-03-07 16:49:54 -05:00
Upgrade Pydantic to V2. --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
28 lines
717 B
Python
28 lines
717 B
Python
from typing import Any
|
|
|
|
import sqlalchemy
|
|
from databases import Database
|
|
from heliclockter import datetime_utc
|
|
|
|
from bracket.config import config
|
|
|
|
|
|
def datetime_decoder(value: str) -> datetime_utc:
|
|
value = value.split(".")[0].replace("+00", "+00:00")
|
|
return datetime_utc.fromisoformat(value)
|
|
|
|
|
|
async def asyncpg_init(connection: Any) -> None:
|
|
for timestamp_type in ("timestamp", "timestamptz"):
|
|
await connection.set_type_codec(
|
|
timestamp_type,
|
|
encoder=datetime_utc.isoformat,
|
|
decoder=datetime_decoder,
|
|
schema="pg_catalog",
|
|
)
|
|
|
|
|
|
database = Database(str(config.pg_dsn), init=asyncpg_init)
|
|
|
|
engine = sqlalchemy.create_engine(str(config.pg_dsn))
|