From ab15313a64e36c59eef48135562b80c64e6dbc36 Mon Sep 17 00:00:00 2001 From: Sam Kleiner Date: Sat, 23 Jun 2018 00:09:53 -0400 Subject: [PATCH] add index to open time --- binance_db/candle.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/binance_db/candle.py b/binance_db/candle.py index 7dac931..ad0945a 100644 --- a/binance_db/candle.py +++ b/binance_db/candle.py @@ -2,7 +2,7 @@ import binance_db.util.constants.ws as ws import binance_db.util.constants.rest as rest from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy import Column, String, Integer, Float, DateTime +from sqlalchemy import Column, String, Integer, Float, DateTime, Index Base = declarative_base() @@ -22,6 +22,11 @@ class Candle(Base): tbbav = Column(Float) tbqav = Column(Float) + __table_args__ = ( + Index('open_time_asc', open_time.asc(), postgresql_using='btree'), + Index('open_time_desc', open_time.desc(), postgresql_using='btree'), + ) + def __init__(self, pair, kline): self.pair = pair self.open_time = self.to_date(kline[rest.OPEN_TIME])