예제 #1
0
def newGame():

    game = session.query(GameGenre)
    # admin = getUserInfo(GameGenre.user_id)

    if 'username' not in login_session:
        return render_template('showgame.html', game=game)
    if request.method == 'POST':
        newGame = GameGenre(name=request.form['name'],
                            user_id=login_session['user_id'])
        session.add(newGame)
        session.commit()
        flash("A new game is created!")
        return redirect(url_for('showGames'))
    else:
        return render_template('newGame.html', game=game)
예제 #2
0
from database_setup import GameGenre, Base, ListGame, User

engine = create_engine('sqlite:///gamelist.db')

Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)

session = DBSession()

firstuser = User(name="admin", email="*****@*****.**")
session.add(firstuser)
session.commit()

# Menu for UrbanBurger
game1 = GameGenre(name="Action", user_id=1)
session.add(game1)
session.commit()

listgame1 = ListGame(
    name="DmC Devil May Cry",
    description="allow the player to tweak gameplay to suit their own style ",
    price='$30',
    games=game1,
    user_id=1)
session.add(listgame1)
session.commit()

listgame2 = ListGame(
    name="Grand Theft Auto 5",
    description="The definitive version of Rockstar's biggest world to date.",
예제 #3
0
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Create dummy user
User1 = User(name="Meng",
             email="*****@*****.**",
             picture='http://mengluo.github.io/me/pics/Avatar.png')
session.add(User1)
session.commit()

# action game genre
gameGenre1 = GameGenre(name="Action Games")

session.add(gameGenre1)
session.commit()

game1 = Game(
    user_id=1,
    name="Street Fighter",
    description=
    """Commonly abbreviated as SF or Suto, is a fighting video game franchise developed and published by Capcom. The first game in the series was released in 1987. Since then, five other main series games, as well as various spin-offs and crossovers, have been released. Street Fighter II is credited with establishing many of the conventions of the one-on-one fighting genre. The game's playable characters originate from different countries around the world, each with a unique fighting style.""",
    game_genre=gameGenre1)

session.add(game1)
session.commit()

game2 = Game(
예제 #4
0
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from database_setup import Base, GameGenre, Game

engine = create_engine('sqlite:///games.db')
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

Arcade = GameGenre(
    name="Arcade",
    description=
    "Games which require the player to navigate a maze or other obstacle")
session.add(Arcade)
session.commit()

Shooter = GameGenre(
    name="Shooter",
    description="Where the main purpose is to fight using guns")
session.add(Shooter)
session.commit()

Strategy = GameGenre(
    name="Strategy",
    description=
    " Where the purpose is to strategize. You have an opponent with the same abilities as you, more or less, and to beat him, you must use your abilities in a much more tactical way"
)
session.add(Strategy)
session.commit()