23 lines
914 B
Python
23 lines
914 B
Python
from sqlalchemy import Column, String, Float, Integer, DateTime, Boolean
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.database import Base
|
|
|
|
class Exchange(Base):
|
|
__tablename__ = "exchanges"
|
|
|
|
id = Column(String, primary_key=True) # exchange_id from the API
|
|
name = Column(String, index=True)
|
|
rank = Column(Integer, index=True)
|
|
percent_total_volume = Column(Float, nullable=True)
|
|
volume_usd = Column(Float, nullable=True)
|
|
trading_pairs = Column(Integer)
|
|
socket = Column(Boolean, nullable=True)
|
|
exchange_url = Column(String, nullable=True)
|
|
updated_timestamp = Column(Integer, nullable=True)
|
|
|
|
# Last time the data was updated in our database
|
|
last_updated = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
|
|
|
def __repr__(self):
|
|
return f"<Exchange {self.name} (Rank: {self.rank})>" |