コード例 #1
0
ファイル: follow_back.py プロジェクト: audiodude/singmytweet
def store_followers(followers):
    #followers is a tuple list of handle_names, handle_ids
    if followers:
        logger.debug('Inserting into follower db: %r', followers)
    else:
        logger.debug('No new followers to insert into db')
    with follower_cursor() as cur:
        cur.executemany("INSERT INTO followers (`handle_name`, `handle_id`) VALUES (?, ?)", followers)
コード例 #2
0
ファイル: follow_back.py プロジェクト: audiodude/singmytweet
def update_follower_db(all_followers):
    new = []
    with follower_cursor() as cur:
        for handle_id in all_followers:
            cur.execute('''
              SELECT 1
              FROM followers 
              WHERE handle_id = ?
            ''', (handle_id,))
            results = cur.fetchone()
            if results:
                continue
            else:
                logger.debug("Found new follower: %s", handle_id)
                new.append(handle_id)

    if new:
        return get_user_info(new)
    else:
        return []
コード例 #3
0
ファイル: follow_back.py プロジェクト: audiodude/singmytweet
def create_sql_tables():
    with follower_cursor() as cur:
        cur.execute('''CREATE TABLE IF NOT EXISTS
                       followers
                       (handle_name text, handle_id text)''')