コード例 #1
0
def work_add():
    #args/input
    args = request.form
    name = args['name']
    content = args['content']

    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})

    #add to table_content
    content_id = myDB.insertQueryBlob(
        'INSERT INTO table_content (content_blob) VALUES (?)', content)
    print(content_id)

    #add to table_work
    sql_work_insert = """
    INSERT INTO table_work (name, content_id, createdate, lastdate, active) 
    VALUES (
    \'""" + name + """\', 
    """ + str(content_id) + """, 
    datetime(\'now\'), 
    datetime(\'now\'),
    1
    )
    """
    work_id = myDB.insertQuery(sql_work_insert)
    return json.dumps([])
コード例 #2
0
def work_get_all():
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    query = """
    SELECT id, name, content_id, createdate, lastdate, active
    FROM
    table_work
    """
    results = myDB.executeQueryDict(query)
    return json.dumps(results)
コード例 #3
0
def work_delete(id):
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    query = """
    UPDATE table_work
    SET active = 0
    WHERE
    id = """ + str(id) + """
    """
    myDB.updateQuery(query)
    return json.dumps([])
コード例 #4
0
ファイル: main.py プロジェクト: Mastakey/python-flask-wnd
def run_main():
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    myQuery = """
    SELECT *
    FROM table_work
    """
    results = myDB.executeQueryDict(myQuery)
    return render_template('main.html',
                           title='My Title',
                           main='My Main',
                           results=results)
コード例 #5
0
ファイル: main.py プロジェクト: Mastakey/python-flask-wnd
def work_get_all():
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    query = """
    SELECT name, content_id, createdate, lastdate, active
    FROM
    table_work
    """
    results = myDB.executeQueryDict(query)
    return render_template('main.html',
                           title='My Title',
                           main='My Main',
                           results=results)
コード例 #6
0
def work_get(id):
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    workquery = """
    SELECT w.id, w.name, w.content_id, w.createdate, w.lastdate, w.active, c.content_blob
    FROM
    table_work w,
    table_content c
    WHERE
    w.content_id = c.id AND
    w.id = """ + str(id) + """
    """
    results = myDB.executeQueryDict(workquery)
    return json.dumps(results)
コード例 #7
0
def main():
    #db config
    dbfile = 'db/nhldata.db'
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    #parser properites config
    f = open('properties.json', 'r')
    props = json.loads(f.read())
    #insertGames only needs to be run once a season to load all games
    insertGames(
        myDB, '2018',
        'https://www.hockey-reference.com/leagues/NHL_2018_games.html', props)
コード例 #8
0
def work_update(id):
    args = request.form
    name = args['name']
    content = args['content']

    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})

    #update to table_content
    myDB.updateQueryBlob(
        'UPDATE table_content SET content_blob=(?) WHERE id=' + str(id),
        content)

    #update to table_work
    sql_work_update = """
    UPDATE table_work
    SET name ='""" + name + """',
    lastdate=datetime(\'now\')
    WHERE id = """ + str(id) + """
    """
    work_id = myDB.insertQuery(sql_work_update)
    return json.dumps([])
コード例 #9
0
def main():
    #db config
    dbfile = 'db/nhldata.db'
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})

    #parser properites config
    f = open('properties.json', 'r')
    props = json.loads(f.read())
    playerfields = props['playerFields']
    goaliefields = props['goalieFields']

    #get all unparsed games
    games = getGames(myDB, '2018')
    for game in games:
        id = game['id']
        link = game['link']
        vteam = game['vteam']
        hteam = game['hteam']
        print(link)
        stats = Boxscore(link, props).getBoxscore()

        vplayers = stats['vteam']['players']
        hplayers = stats['hteam']['players']

        vgoalies = stats['vteam']['goalies']
        hgoalies = stats['hteam']['goalies']

        for vplayer in vplayers:
            insertPlayerStats(myDB, id, vteam, hteam, vplayer, playerfields)
        for hplayer in hplayers:
            insertPlayerStats(myDB, id, hteam, vteam, hplayer, playerfields)

        for vgoalie in vgoalies:
            insertGoalieStats(myDB, id, vteam, hteam, vgoalie, goaliefields)
        for hgoalie in hgoalies:
            insertGoalieStats(myDB, id, hteam, vteam, hgoalie, goaliefields)
        updateGameParsed(myDB, id)
        time.sleep(2)
コード例 #10
0
def getApp():
    #gets the APP object
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})
    myApp = APP(myDB, [])
    return myApp
コード例 #11
0
ファイル: main.py プロジェクト: Mastakey/python-flask-wnd
def work_add():
    myDB = WEBDB(dbfile, {'logging': 'on', 'type': 'sqlite'})