Merge pull request #10 from vertti/fix-persistent-session
Fix Session lint issues
This commit is contained in:
commit
ddc984bd02
1
.gitignore
vendored
1
.gitignore
vendored
@ -80,3 +80,4 @@ preprocessor.py
|
||||
.env
|
||||
.venv
|
||||
.idea
|
||||
.vscode
|
||||
|
@ -2,7 +2,9 @@ from datetime import datetime
|
||||
|
||||
from sqlalchemy import Boolean, Column, DateTime, Float, Integer, String, create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import scoped_session, sessionmaker
|
||||
from sqlalchemy.orm.scoping import scoped_session
|
||||
from sqlalchemy.orm.session import sessionmaker
|
||||
|
||||
from sqlalchemy.types import Enum
|
||||
|
||||
from exchange import Exchange, get_exchange_api
|
||||
@ -15,14 +17,13 @@ else:
|
||||
db_handle = 'sqlite:///tradesv2.sqlite'
|
||||
|
||||
engine = create_engine(db_handle, echo=False)
|
||||
Session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
|
||||
session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
|
||||
Session = session()
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
class Trade(Base):
|
||||
__tablename__ = 'trades'
|
||||
|
||||
query = Session.query_property()
|
||||
query = session.query_property()
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
exchange = Column(Enum(Exchange), nullable=False)
|
||||
|
@ -244,7 +244,6 @@ class TelegramHandler(object):
|
||||
if not get_instance().is_alive():
|
||||
TelegramHandler.send_msg('`trader is not running`', bot=bot)
|
||||
return
|
||||
|
||||
pair_rates = Session.query(Trade.pair, func.sum(Trade.close_profit).label('profit_sum')) \
|
||||
.filter(Trade.is_open.is_(False)) \
|
||||
.group_by(Trade.pair) \
|
||||
|
Loading…
Reference in New Issue
Block a user