Skip to content

Instantly share code, notes, and snippets.

@rtuita23
Created February 1, 2015 00:36
Show Gist options
  • Save rtuita23/bcabefd4a8f6d4b64f70 to your computer and use it in GitHub Desktop.
Save rtuita23/bcabefd4a8f6d4b64f70 to your computer and use it in GitHub Desktop.
tbay
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime
engine = create_engine('postgresql://action:action@localhost:5432/tbay')
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
class Item(Base):
__tablename__ = "items"
id = Column(Integer, primary_key=True)
name = Column(String, nullable=False)
description = Column(String)
start_time = Column(DateTime, default=datetime.utcnow)
print 'after class item'
class User(Base):
__tablename__="name"
id = Column(Integer, primary_key=True)
username = Column(String, nullable=False)
password = Column(String, nullable=False)
print 'after class item'
class Bid(Base):
__tablename__="bid"
id = Column(Integer, primary_key=True)
price = Column(Floating, nullable=False)
print 'after base'
Base.metadata.create_all(engine)
print 'after Base'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment