You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB

7 years ago
import marshmallow
import sqlalchemy
import sqlalchemy.orm
import sqlalchemy.ext.declarative
from datetime import datetime
engine = sqlalchemy.create_engine('sqlite:////tmp/quotes.db') # FIXME
Session = sqlalchemy.orm.sessionmaker(bind=engine)
Base = sqlalchemy.ext.declarative.declarative_base()
class Quote(Base):
__tablename__ = 'quotes'
id = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
video_id = sqlalchemy.Column(sqlalchemy.Integer)
date = sqlalchemy.Column(sqlalchemy.Date)
game = sqlalchemy.Column(sqlalchemy.String)
text = sqlalchemy.Column(sqlalchemy.String)
created_at = sqlalchemy.Column(sqlalchemy.DateTime)
updated_at = sqlalchemy.Column(sqlalchemy.DateTime)
def __init__(self, id, video_id, date, game, text):
self.id = id
self.video_id = video_id
self.date = date
self.game = game
self.text = text
self.created_at = datetime.now()
self.updated_at = datetime.now()
class QuoteSchema(marshmallow.Schema):
id = marshmallow.fields.Integer()
video_id = marshmallow.fields.Integer()
date = marshmallow.fields.Date()
game = marshmallow.fields.Str()
text = marshmallow.fields.Str()
created_at = marshmallow.fields.DateTime()
updated_at = marshmallow.fields.DateTime()