Skip to content

Instantly share code, notes, and snippets.

@bosukh
Last active December 25, 2017 06:40
Show Gist options
  • Save bosukh/4b9eba4055f210aac88a15c825c9c9a6 to your computer and use it in GitHub Desktop.
Save bosukh/4b9eba4055f210aac88a15c825c9c9a6 to your computer and use it in GitHub Desktop.
from sqlalchemy import Column, Integer, String, DateTime
def Trasaction(Base, year, month, day):
month = "{:02d}".format(month)
day = "{:02d}".format(day)
class Trasaction(Base):
__tablename__ = 'card_trasaction_{year}_{month}_{day}'.format(
year=year, month=month, day = day
)
__table_args__ = (
{'extend_existing':True,
'mysql_engine': 'InnoDB'},
)
id = Column(Integer, primary_key=True, autoincrement=True)
timestamp = Column(DateTime, nullable=False, index=True)
amount = Column(Integer, nullable=False, index=True)
card_num = Column(String(24), nullable=False, index=True)
return Trasaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment