Move SessionType to base module

This commit is contained in:
Matthias 2023-02-28 07:03:22 +01:00
parent f2f4158974
commit d175ab495b
4 changed files with 7 additions and 8 deletions

View File

@ -1,6 +1,8 @@
from sqlalchemy.orm import DeclarativeBase from sqlalchemy.orm import DeclarativeBase, Session, scoped_session
SessionType = scoped_session[Session]
class ModelBase(DeclarativeBase): class ModelBase(DeclarativeBase):
pass pass

View File

@ -6,11 +6,11 @@ from typing import Any, Dict
from sqlalchemy import create_engine, inspect from sqlalchemy import create_engine, inspect
from sqlalchemy.exc import NoSuchModuleError from sqlalchemy.exc import NoSuchModuleError
from sqlalchemy.orm import Session, scoped_session, sessionmaker from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.pool import StaticPool from sqlalchemy.pool import StaticPool
from freqtrade.exceptions import OperationalException from freqtrade.exceptions import OperationalException
from freqtrade.persistence.base import ModelBase from freqtrade.persistence.base import ModelBase, SessionType
from freqtrade.persistence.migrations import check_migrate from freqtrade.persistence.migrations import check_migrate
from freqtrade.persistence.pairlock import PairLock from freqtrade.persistence.pairlock import PairLock
from freqtrade.persistence.trade_model import Order, Trade from freqtrade.persistence.trade_model import Order, Trade
@ -20,7 +20,6 @@ logger = logging.getLogger(__name__)
_SQL_DOCS_URL = 'http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls' _SQL_DOCS_URL = 'http://docs.sqlalchemy.org/en/latest/core/engines.html#database-urls'
SessionType = scoped_session[Session]
def init_db(db_url: str) -> None: def init_db(db_url: str) -> None:

View File

@ -6,8 +6,7 @@ from sqlalchemy.orm import Mapped, Query, mapped_column
from sqlalchemy.orm.scoping import _QueryDescriptorType from sqlalchemy.orm.scoping import _QueryDescriptorType
from freqtrade.constants import DATETIME_PRINT_FORMAT from freqtrade.constants import DATETIME_PRINT_FORMAT
from freqtrade.persistence.base import ModelBase from freqtrade.persistence.base import ModelBase, SessionType
from freqtrade.persistence.models import SessionType
class PairLock(ModelBase): class PairLock(ModelBase):

View File

@ -17,8 +17,7 @@ from freqtrade.enums import ExitType, TradingMode
from freqtrade.exceptions import DependencyException, OperationalException from freqtrade.exceptions import DependencyException, OperationalException
from freqtrade.exchange import amount_to_contract_precision, price_to_precision from freqtrade.exchange import amount_to_contract_precision, price_to_precision
from freqtrade.leverage import interest from freqtrade.leverage import interest
from freqtrade.persistence.base import ModelBase from freqtrade.persistence.base import ModelBase, SessionType
from freqtrade.persistence.models import SessionType
from freqtrade.util import FtPrecise from freqtrade.util import FtPrecise