Last active
December 25, 2017 06:40
-
-
Save bosukh/4b9eba4055f210aac88a15c825c9c9a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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