Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created February 9, 2012 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphbean/1779952 to your computer and use it in GitHub Desktop.
Save ralphbean/1779952 to your computer and use it in GitHub Desktop.
tg2app/model/stuff.py
# -*- coding: utf-8 -*-
"""My Login Modules stuff."""
from sqlalchemy import *
from sqlalchemy.orm import mapper, relation
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Integer, Unicode, DateTime
#from sqlalchemy.orm import relation, backref
from datetime import datetime
from tg2app.model import DeclarativeBase, metadata, DBSession
class Login(DeclarativeBase):
__tablename__ = 'logins'
id = Column(Integer, primary_key=True)
name = Column(Unicode(255), nullable=False)
access_token = Column(Unicode(255), nullable=False)
last_seen = Column(DateTime, nullable=False)
def __json__(self):
return {
'name': self.name,
}
class Message(DeclarativeBase):
__tablename__ = 'messages'
id = Column(Integer, primary_key=True)
msg = Column(Unicode(255), nullable=False)
created_on = Column(DateTime, nullable=False, default=datetime.now)
def __json__(self):
return {
'msg': self.msg,
}
# (you also have to edit tg2app/model/__init__.py, do you know what to add there?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment