Exemplo n.º 1
0
def put():
    finished = False
    while not finished:
        newuser = User()
        print "Please enter the name you would like to use for your user name: "
        newuser.username = raw_input()
        print "Please enter the password you would like to associate with this account:"
        newuser.password = raw_input()
        session.add(newuser)
        session.commit()
        print "Would you like to create additional accounts? Y/N: "
        answer = raw_input()
        if answer == "n":
            main()
Exemplo n.º 2
0
def main():

    # add users
    beyonce = User(username="******", password="******")
    ariana = User(username="******", password="******")
    miley = User(username="******", password="******")
    session.add_all([beyonce, ariana, miley])
    session.commit()

    # Make one user auction a baseball
    baseball = Item(name="baseball",
                    description="Baseball from Babe Ruth's first home run",
                    seller=ariana)
    session.add(baseball)
    session.commit()
    print("{} started an auction for {} at {}".format(
        baseball.seller, baseball.name,
        baseball.start_time.strftime('%m/%d/%y')))

    # Have each other use two bids on the baseball
    starting_bid = Bid(price=100.00, item=baseball, bidder=ariana)
    bknowles_bid = Bid(price=150.00, item=baseball, bidder=beyonce)
    mcyrus_bid = Bid(price=200.00, item=baseball, bidder=miley)

    bid_list = [bknowles_bid, mcyrus_bid]
    session.add_all([starting_bid, bknowles_bid, mcyrus_bid])
    session.commit()

    for bid in bid_list:
        print("{} placed a bid on a {} for {}".format(bid.bidder, bid.item,
                                                      bid.price))

    # Perform a query to find out which user placed the highest bid
    highest_bid = session.query(Bid).order_by(Bid.price.desc()).first()
    print("{} had the highest bid at ${}".format(highest_bid.bidder.username,
                                                 highest_bid.price))
Exemplo n.º 3
0
#!/usr/bin/python

from tbay import session, Item, User, Bid

chris = User() 
chris.username = "******" 
chris.password = "******"
session.add(chris)
session.commit()

ashley = User(username = "******", password = "******")
session.add(ashley)
session.commit()

lianna = User(username = "******", password = "******")
session.add(lianna)
session.commit()

baseball = Item()
baseball.name = "Giants World Series 2014"
baseball.description = "Foul ball in game 2"
chris.items.append(baseball)
session.add(baseball)
session.commit()

guitar = Item(name = "Fender", description = "rock out with this electric guitar")
ashley.items.append(guitar)
session.add(guitar)
session.commit()

bid_ashley = Bid(price = 5000, item = baseball, bidder = ashley)
Exemplo n.º 4
0
from tbay import User, Item, Bid, session
from datetime import datetime

john = User()
john.id = 1
john.username = "******"
john.password = "******"
session.add(john)
session.commit()

angela = User()
angela.id = 2
angela.username = "******"
angela.password = "******"
session.add(angela)
session.commit()

car = Item()
car.id = 1
car.name = "honda"
car.description = "2005 japanese car in blue"
session.add(car)
session.commit()

bike = Item()
bike.id = 2
bike.name = "gt"
bike.description = "2012 black bicycle"
session.add(bike)
session.commit()
Exemplo n.º 5
0
from tbay import User, Item, Bid, session

beyonce = User()
beyonce.username = "******"
beyonce.password = "******"
session.add(beyonce)

patricia = User(username="******", password="******")
session.add(patricia)

session.commit()

# Returns a list of all of the user objects
# Note that user objects won't display very prettily by default -
# you'll see their type (User) and their internal identifiers.

session.query(User).all()  # Returns a list of all of the user objects

# Returns the first user
session.query(User.username).first()

# Finds the user with the primary key equal to 1
session.query(User).get(1)

# Returns a list of all of the usernames in ascending order
session.query(User.username).order_by(User.username).all()

# # Returns the description of all of the basesballs
# session.query(Item.description).filter(Item.name == "baseball").all()

# Return the item id and description for all baseballs which were created in the past.  Remember to import the datetime object: from datetime import datetime
Exemplo n.º 6
0
Arquivo: test.py Projeto: rasalt/tbay
from sqlalchemy import Table, Column, Integer, String, ForeignKey, Float, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from datetime import datetime
from tbay import User, Bid, Item
engine = create_engine('postgresql://*****:*****@localhost:5432/tbay')
Session = sessionmaker(bind=engine)
session = Session()

# Adding users to the tbay database
user1 = User(name="Ruchika", password="******")
user2 = User(name="Shilpa", password="******")
user3 = User(name="Akanskha", password="******")
session.add(user1)
session.add(user2)
session.add(user3)

item1 = Item(name="BallR", description="Red Ball", cost=5.25)
item2 = Item(name="BallY", description="Yellow Ball", cost=6.25)
item3 = Item(name="BallG", description="Green Ball", cost=7.25)

session.add_all([item1, item2, item3])
session.commit()

user1.sell = [item1, item2]
session.commit()

#List the items a user is selling
Exemplo n.º 7
0
Arquivo: text.py Projeto: yueyehm/Tbay
from tbay import User, Item, Bid, session

perry = User(name="Perry",password="******")
baseball = Item(name="BaseBall")
perry.items = [baseball]
jesse = User(name="Jesse",password="******")
monica = User(name="Monica",password="******")
bid1 = Bid(price=23.8,bidder=jesse,item=baseball)
bid2 = Bid(price=18.5, bidder=monica,item=baseball)

session.add_all([perry, jesse, monica, baseball, bid1, bid2])
session.commit()
highestBid = session.query(Bid).order_by(Bid.price.desc()).first()
print(highestBid.price, highestBid.bidder.name)
Exemplo n.º 8
0
from tbay import Item, User, Bid, session

#add three users to the database
"""
jp = User(username="******", password="******")
jenna = User(username="******", password="******")
jaimie = User(username="******", password="******")
"""

jp = User()
jp.username = "******"
jp.password = "******"
session.add(jp)
session.commit()

jenna = User()
jenna.username = "******"
jenna.password = "******"
session.add(jenna)
session.commit()


baseball = Item()
baseball.name='1986 World Series Baseball'
baseball.description='A baseball signed by the 1986 NY Mets'
baseball.user=jp
session.add(baseball)
session.commit()

shirt = Item()
shirt.name='U2 World Tour'
Exemplo n.º 9
0
from tbay import User, Item, Bid, session

beyonce = User()
beyonce.username = "******"
beyonce.password = "******"

sylvester = User()
sylvester.username = "******"
sylvester.password = "******"

jayz = User()
jane.username = "******"
jane.password = "******"

Base.metadata.create_all(engine)

session.add_all([beyonce, sylvester, jayz])
session.commit()

baseball = Item()
headphones.name = "baseball"
headphones.description = "Who wants to play ball? Get your baseball here!"
session.add(baseball)
session.commit()
Exemplo n.º 10
0
Arquivo: main.py Projeto: eunnah/tbay
from tbay import User, Item, Bid, session

beyonce = User()
beyonce.username = "******"
beyonce.password = "******"
beyonce.id = "78"
session.add(beyonce)
session.commit()

jayz = User()
jayz.username = "******"
jayz.password = "******"
jayz.id = "56"
session.add(jayz)
session.commit()

solange = User()
solange.username = "******"
solange.password = "******"
solange.id = "1234"
session.add(solange)
session.commit()

crown = Item()
crown.name = "crown"
crown.description = "a beautiful crown"
crown.seller_id = solange.id
session.add(crown)
session.commit()

baseball = Item()
Exemplo n.º 11
0
from tbay import Item, User, Bid, session
from sqlalchemy import desc

#add three users to the database
"""
jp = User(username="******", password="******")
jenna = User(username="******", password="******")
jaimie = User(username="******", password="******")
"""

jp = User()
jp.username = "******"
jp.password = "******"
session.add(jp)
session.commit()

jenna = User()
jenna.username = "******"
jenna.password = "******"
session.add(jenna)
session.commit()

jaimie = User()
jaimie.username = "******"
jaimie.password = "******"
session.add(jaimie)
session.commit()

#make one user auction a baseball
'''
baseball = Item(name='1986 World Series Baseball', description='A baseball signed by the 1986 NY Mets', start_time='', owner=jp)
Exemplo n.º 12
0
#!/usr/bin/env python

from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.ext.declarative import declarative_base

engine = create_engine("postgresql://codio@localhost:5432/tbay")
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()

from tbay import Item, User, Bid

user1 = User(username="******", password="******")
user2 = User(username="******", password="******")
session.add_all([user1, user2])
session.commit()

item1 = Item(name="doodad", owner=user1)
item2 = Item(name="foodad", owner=user2)

session.add_all([item1, item2])
session.commit()

bid1 = Bid(price=100.0, bidder_id=user1, item_id=item2)
bid2 = Bid(price=200.0, bidder_id=user2, item_id=item1)

session.add_all([bid1, bid2])
session.commit()
Exemplo n.º 13
0
from tbay import Item, User, Bid, session

jp = User()
jp.username = "******"
jp.password = "******"
session.add(jp)
session.commit()

jenna = User()
jenna.username = "******"
jenna.password = "******"
session.add(jenna)
session.commit()

toy = Item()
toy.name = "boat"
toy.user = jp
session.add(toy)
session.commit()

user_jp = session.query(User).filter(User.username == "jpc").first()
print(user_jp)
print(user_jp.username)
print(jp.items)

find_users = session.query(User).all()
print(find_users)
Exemplo n.º 14
0
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

engine = create_engine('postgresql://localhost:5432/tbay3')
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()

from tbay import User, Item, Bid

kyle = User(username='******')
zach = User(username='******')
leigh = User(username='******')

session.add_all([kyle, zach, leigh])
session.commit()

baseball = Item(name='mlb baseball', owner=kyle)
football = Item(name='nfl football', owner=zach)
piano = Item(name='grand piano', owner=leigh)

session.add_all([baseball, football, piano])
session.commit()

bid01 = Bid(price=17.50, bidder=kyle, auction_item=football)
bid02 = Bid(price=5175, bidder=zach, auction_item=piano)
bid03 = Bid(price=21.25, bidder=leigh, auction_item=football)
bid04 = Bid(price=18.75, bidder=zach, auction_item=football)
bid05 = Bid(price=27.00, bidder=kyle, auction_item=football)
bid06 = Bid(price=5500, bidder=kyle, auction_item=piano)
Exemplo n.º 15
0
from tbay import User, Item, Bid, session

# Create Larisa
larisa = User(username='******', password='******')
session.add(larisa)

# Create Jesse
jesse = User(username='******', password='******')
session.add(jesse)

# Create Brendan
brendan = User(username='******', password='******')
session.add(brendan)

session.commit()

# Add a baseball
baseball = Item(name='baseball',
                description='A very nice baseball indeed',
                seller=jesse)
session.add(baseball)
session.commit()

# Larisa and Brendan bid
lbid = Bid(price=0.20, item=baseball, bidder=larisa)
bbid = Bid(price=0.25, item=baseball, bidder=brendan)
session.add(lbid)
session.add(bbid)
session.commit()

# Find the highest bid
Exemplo n.º 16
0
from tbay import User, Item, Bid, session
from datetime import datetime
#name = Column(String, nullable=False)
#password = Column(String, nullable=False)
Eminem = User(id=2, name="Eminem", password="******")
Coldplay = User(id=3, name="Coldplay", password="******")

baseballr = Item(id=1,
                 name="baseball",
                 description="Red",
                 start_time=datetime.utcnow())

basebally = Item(id=2,
                 name="baseball",
                 description="Yellow",
                 start_time=datetime.utcnow())
baseballv = Item(id=3,
                 name="baseball",
                 description="Violet",
                 start_time=datetime.utcnow())

session.add(Eminem)
session.add(Coldplay)

session.add(baseballr)
session.add(basebally)
session.add(baseballv)

session.commit()

#id = Column(Integer, primary_key=True)