Update DeclarativeBase

This commit is contained in:
Matthias 2023-02-16 07:04:45 +00:00
parent 3c019e0e16
commit 39a658eac2
4 changed files with 11 additions and 12 deletions

View File

@ -1,7 +1,6 @@
from typing import Any from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import declarative_base
_DECL_BASE: Any = declarative_base() class ModelBase(DeclarativeBase):
pass

View File

@ -10,7 +10,7 @@ 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 _DECL_BASE from freqtrade.persistence.base import ModelBase
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
@ -60,5 +60,5 @@ def init_db(db_url: str) -> None:
PairLock.query = Trade._session.query_property() PairLock.query = Trade._session.query_property()
previous_tables = inspect(engine).get_table_names() previous_tables = inspect(engine).get_table_names()
_DECL_BASE.metadata.create_all(engine) ModelBase.metadata.create_all(engine)
check_migrate(engine, decl_base=_DECL_BASE, previous_tables=previous_tables) check_migrate(engine, decl_base=ModelBase, previous_tables=previous_tables)

View File

@ -5,10 +5,10 @@ from sqlalchemy import Boolean, Column, DateTime, Integer, String, or_
from sqlalchemy.orm import Query from sqlalchemy.orm import Query
from freqtrade.constants import DATETIME_PRINT_FORMAT from freqtrade.constants import DATETIME_PRINT_FORMAT
from freqtrade.persistence.base import _DECL_BASE from freqtrade.persistence.base import ModelBase
class PairLock(_DECL_BASE): class PairLock(ModelBase):
""" """
Pair Locks database model. Pair Locks database model.
""" """

View File

@ -17,14 +17,14 @@ 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 _DECL_BASE from freqtrade.persistence.base import ModelBase
from freqtrade.util import FtPrecise from freqtrade.util import FtPrecise
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class Order(_DECL_BASE): class Order(ModelBase):
""" """
Order database model Order database model
Keeps a record of all orders placed on the exchange Keeps a record of all orders placed on the exchange
@ -1161,7 +1161,7 @@ class LocalTrade():
logger.info(f"New stoploss: {trade.stop_loss}.") logger.info(f"New stoploss: {trade.stop_loss}.")
class Trade(_DECL_BASE, LocalTrade): class Trade(ModelBase, LocalTrade):
""" """
Trade database model. Trade database model.
Also handles updating and querying trades Also handles updating and querying trades