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)
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 []
def create_sql_tables(): with follower_cursor() as cur: cur.execute('''CREATE TABLE IF NOT EXISTS followers (handle_name text, handle_id text)''')