Skip to content
Permalink
92f112dc37
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
28 lines (19 sloc) 870 Bytes
import datetime
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.schema import Column
from sqlalchemy.types import DateTime, Integer, Unicode
engine = create_engine('postgresql:///guestbook_demo')
session = scoped_session(sessionmaker(bind=engine, autoflush=False))
Base = declarative_base(bind=engine)
### Yonder tables
class GuestbookEntry(Base):
__tablename__ = 'guestbook_entries'
id = Column(Integer, primary_key=True, nullable=False)
timestamp = Column(DateTime, nullable=False, index=True)
name = Column(Unicode, nullable=False)
message = Column(Unicode, nullable=False)
def __init__(self, **kwargs):
kwargs.setdefault('timestamp', datetime.utcnow())
super(GuestbookEntry, self).__init__(**kwargs)