Skip to content

Commit

Permalink
Merge pull request #746 from Kwaizer/bs_203_sqla_v2
Browse files Browse the repository at this point in the history
Migrate Sqlalcehmy to the v2
  • Loading branch information
Korulag authored Mar 11, 2024
2 parents 38a1d2e + 835ce8b commit 2e54521
Show file tree
Hide file tree
Showing 4 changed files with 1,010 additions and 607 deletions.
25 changes: 19 additions & 6 deletions alws/database.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# -*- mode:python; coding:utf-8; -*-
# author: Vyacheslav Potoropin <[email protected]>
# created: 2021-06-22
from sqlalchemy import create_engine
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import MetaData, create_engine
from sqlalchemy.ext.asyncio import (
AsyncAttrs,
AsyncSession,
create_async_engine,
)
from sqlalchemy.orm import DeclarativeBase, scoped_session, sessionmaker
from sqlalchemy.pool import NullPool

from alws.config import settings
Expand All @@ -18,12 +21,22 @@
sync_engine = create_engine(
settings.sync_database_url, pool_pre_ping=True, pool_recycle=3600
)
Base = declarative_base()


class Base(AsyncAttrs, DeclarativeBase):
__allow_unmapped__ = True
metadata = MetaData()


sync_session_factory = sessionmaker(sync_engine, expire_on_commit=False)
Session = sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
SyncSession = scoped_session(sync_session_factory)

PulpBase = declarative_base()

class PulpBase(AsyncAttrs, DeclarativeBase):
__allow_unmapped__ = True


pulp_engine = create_engine(
settings.pulp_database_url, pool_pre_ping=True, pool_recycle=3600
)
Expand Down
Loading

1 comment on commit 2e54521

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total coverage

Coverage report for changed files •
FileStmtsMissCoverMissing
database.py200100% 
models.py6353794%112, 121, 289, 582, 628, 1027, 1497–1499, 1502–1504, 1511, 1660–1661, 1665–1666, 1669–1671, 1795–1797, 1800–1802, 1809, 1956–1957, 1961–1962, 1965–1967, 2094–2095, 2099
pulp_models.py206796%249, 453, 456, 460, 464, 472, 500
TOTAL9854432956% 

Tests Skipped Failures Errors Time
81 2 💤 0 ❌ 0 🔥 43.687s ⏱️

Please sign in to comment.