Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
petshop/model.py
from sqlalchemy import Column, DateTime, Integer, String
from db import db_session, Base
class Pet(Base):
__tablename__ = 'pets'
id = Column(Integer, primary_key=True)
name = Column(String(100))
tag = Column(String(20))
created = Column(DateTime())
def update(self, id=None, name=None, tag=None, created=None):
if name is not None:
self.name = name
if tag is not None:
self.tag = tag
if created is not None:
self.created = created
def as_dict(self):
return dict([(k, v) for k, v in vars(self).items() if not k.startswith('_')])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment