Пример #1
0
def set_can_vote(user_id, can_vote):
    cursor = dbc.cursor()
    sql = """
        update users 
        set can_vote = ?
        where user_id = ?
    """
    cursor.execute(sql, (can_vote, user_id))
    dbc.commit()
Пример #2
0
def pitch_game(game_id, user_id, pitch):
    cursor = dbc.cursor()

    sql = """
        insert into game_pitches(game_id, user_id, pitch)
        values (?, ?, ?)
    """
    cursor.execute(sql, (game_id, user_id, pitch))
    dbc.commit()
Пример #3
0
def register_user(user_id, username, avatar_url):
    cursor = dbc.cursor()
    sql = """
        insert into users (user_id, username, avatar_url) 
        values (?,?,?) 
        ON CONFLICT(user_id) DO 
        UPDATE SET username = ?, avatar_url = ?
        where user_id = ?
    """
    cursor.execute(
        sql, (user_id, username, avatar_url, username, avatar_url, user_id))
    dbc.commit()
Пример #4
0
def vote_game(poll, game_id, user_id, upvote):
    cursor = dbc.cursor()

    sql = """
        insert into votes(poll, game_id, user_id, vote)
        values (?, ?, ?, ?)
        ON CONFLICT(poll, game_id, user_id) DO 
        UPDATE SET vote = ?
        where poll = ? and game_id = ? and user_id = ?

    """
    cursor.execute(
        sql, (poll, game_id, user_id, upvote, upvote, poll, game_id, user_id))
    dbc.commit()