Created
February 9, 2012 13:31
-
-
Save ralphbean/1779952 to your computer and use it in GitHub Desktop.
tg2app/model/stuff.py
This file contains 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
# -*- 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