Exemplo n.º 1
0
def update_champions(db):
    champions = riot_api.get_champions()
    for champ in champions:
        id = int(champions[champ]['key'])
        img_url = champions[champ]['image']['full']
        db.execute('insert into champions (id, img_url) values (?, ?)',
                   [id, img_url])
Exemplo n.º 2
0
def init_db():
    with closing(connect_db()) as db:
        with app.open_resource('schema.sql', mode='r') as f:
            db.cursor().executescript(f.read())
        items = riot_api.get_items()
        for item in items:
            item_data = items[item]
            gold = item_data['gold']
            db.execute('insert into items (id, name, img_url, base_cost, full_cost) values (?, ?, ?, ?, ?)',
                 [item, item_data['name'], item_data['image']['full'], gold['base'], gold['total']])
        champions = riot_api.get_champions()
        for champ in champions:
            id = int(champions[champ]['key'])
            img_url = champions[champ]['image']['full']
            db.execute('insert into champions (id, img_url) values (?, ?)', [id, img_url])
        db.commit()
Exemplo n.º 3
0
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship
from sqlalchemy.sql import select
from datetime import datetime, timedelta
import riot_api
import pickle
import os

# Set up sqlite3 with sqlalchemy
engine = create_engine('sqlite:///data.db')
Base = declarative_base()
Session = sessionmaker()
Session.configure(bind=engine)

# Get champion data from the api
champions = riot_api.get_champions()
# Get item data from the api
items = riot_api.get_items()


class Match(Base):
    """ Schema for Matches """
    __tablename__ = 'matches'

    match_id = Column(Integer, primary_key=True)
    region = Column(String)
    created_on = Column(DateTime)
    duration = Column(Interval)
    version = Column(String, index=True)
    items_bought = relationship("BoughtItems")
Exemplo n.º 4
0
def update_champions(db):
    champions = riot_api.get_champions()
    for champ in champions:
        id = int(champions[champ]['key'])
        img_url = champions[champ]['image']['full']
        db.execute('insert into champions (id, img_url) values (?, ?)', [id, img_url])