コード例 #1
0
ファイル: database.py プロジェクト: lagolucas/7c0-core
def list_apagados_novo(arroba):
    db = database_auth.conecta_banco()
    sql = "select idTweets,plain_text,timestamp_tw from mimic_tweets where handle =\"" + arroba + "\" and erased = 1;"
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    db.close()
    return value
コード例 #2
0
ファイル: database.py プロジェクト: lagolucas/twitter-mimic
def recupera_ids(conta):
    sql = "select idTweets from mimic_tweets where handle = \""+conta+"\";"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    db.close()
    return value
コード例 #3
0
ファイル: database.py プロジェクト: lagolucas/7c0-core
def recupera_ids_sem_arquivo2():
    sql = "select idTweets, handle from mimic_tweets where archive_url is null order by idTweets DESC limit 5"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    db.close()
    return value
コード例 #4
0
def lock_tweets():
    sql = "update mimic_tweets set check_erased = 1 where erased = 0;"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
    except Exception as E:
        print(E)
    finally:
        db.commit()
        db.close()
コード例 #5
0
ファイル: database.py プロジェクト: lagolucas/7c0-core
def update_tweet(id):
    sql = "update mimic_tweets set erased = 1, 7c0_tweeted = 1, timestamp_erased = \"" + datetime.datetime.now(
    ).strftime("%Y-%m-%d %H:%M:%S") + "\" where idTweets = \"" + id + "\";"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
    except Exception as E:
        print(E)
    db.commit()
    db.close()
コード例 #6
0
ファイル: database.py プロジェクト: lagolucas/7c0-core
def adiciona_arquivo(id, url_arquivo):
    sql = "update mimic_tweets set archive_url =\"" + url_arquivo + "\" where idTweets = \"" + str(
        id) + "\";"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
    except Exception as E:
        print(E)
    db.commit()
    db.close()
コード例 #7
0
ファイル: database.py プロジェクト: lagolucas/twitter-mimic
def get_last_id():
    db = database_auth.conecta_banco()
    sql = "select max(idTweets) from mimic_tweets;"
    cursor = db.cursor()
    value = ""
    try:
        cursor.execute(sql)
        value = cursor.fetchone()
    except Exception as E:
        print(E)
    db.close()
    return value[0]
コード例 #8
0
ファイル: database.py プロジェクト: lagolucas/7c0-core
def get_oldest_id(arroba):
    db = database_auth.conecta_banco()
    sql = "select min(idTweets) from mimic_tweets where handle = \"" + arroba + "\";"
    cursor = db.cursor()
    value = ""
    try:
        cursor.execute(sql)
        value = cursor.fetchone()
    except Exception as E:
        print(E)
    db.close()
    return value[0]
コード例 #9
0
def get_handles_to_tweet():
    sql = "select distinct(handle) from mimic_tweets where erased = 1 and 7c0_tweeted = 0;"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    finally:
        db.close()

    return value
コード例 #10
0
def get_candidatos():
    sql = "select * from candidatos_2020;"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    finally:
        db.close()

    return value
コード例 #11
0
def update_erased_tweets_election(id_set):
    db = database_auth.conecta_banco()
    cursor = db.cursor()

    for id in id_set:
        sql = "update election_tweets_2020 set timestamp_erased = NOW(), erased = 1, check_erased = 2 where idTweets = \"" + id + "\";"
        try:
            cursor.execute(sql)
        except Exception as E:
            print(E)

    db.commit()
    db.close()
コード例 #12
0
def get_ids_election():
    sql = "select idTweets from election_tweets_2020 where check_erased = 1;"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    finally:
        db.close()

    return value
コード例 #13
0
ファイル: database.py プロジェクト: projeto7c0/7c0-captures
def recupera_ids_total_election():
    db = database_auth.conecta_banco()
    sql = "select max(idTweets) from election_tweets_2020;"
    cursor = db.cursor()
    value = ""
    try:
        cursor.execute(sql)
        value = cursor.fetchone()
    except Exception as E:
        print(E)
    db.close()
    print(value)
    return value[0]
コード例 #14
0
def get_tweets_ids_election(conta):
    print(conta)
    sql = "select idTweets from election_tweets_2020 where handle = \"" + conta[
        1] + "\" and 7c0_tweeted = 0 and erased = 1 order by idTweets asc;"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchall()
    except Exception as E:
        print(E)
    finally:
        db.close()

    return value
コード例 #15
0
def update_tweeted_election(id_set):
    db = database_auth.conecta_banco()
    cursor = db.cursor()

    sql = "update election_tweets_2020 set 7c0_tweeted = 1 where idTweets in ("

    for id in id_set:
        sql += "\"" + str(id[0]) + "\","

    sql += "\"0\");"

    try:
        cursor.execute(sql)
    except Exception as E:
        print(E)

    db.commit()
    db.close()
コード例 #16
0
def update_checked(id_set):
    db = database_auth.conecta_banco()
    cursor = db.cursor()

    sql = "update mimic_tweets set check_erased = 2 where idTweets in ("

    for id in id_set:
        sql += "\"" + str(id[0]) + "\","

    sql += "\"0\");"

    # print(sql)
    try:
        cursor.execute(sql)
    except Exception as E:
        print(E)

    db.commit()
    db.close()
コード例 #17
0
def retrieve_tweet_election(tweet_id):
    sql = "select * from election_tweets_2020 where idTweets = \"" + str(
        tweet_id[0]) + "\";"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchone()
    except Exception as E:
        print(E)
    finally:
        db.close()

    if value:
        if value[11]:
            return tweet_id, value[2], value[4], value[11], value[3]
        else:
            return tweet_id, value[2], value[4], "Não arquivado", value[3]
    else:
        return [0], "", "", "Não arquivado", ""
コード例 #18
0
ファイル: database.py プロジェクト: lagolucas/7c0-core
def retrieve_tweet(twitter_url):
    tweet_id = twitter_url.split("/")[-1]
    # print(tweet_id)
    sql = "select * from mimic_tweets where idTweets = \"" + tweet_id + "\" and 7c0_tweeted = 0;"
    db = database_auth.conecta_banco()
    cursor = db.cursor()
    try:
        cursor.execute(sql)
        value = cursor.fetchone()
    except Exception as E:
        print(E)
    finally:
        db.close()

    if value:
        if value[10]:
            return tweet_id, value[2], value[4], value[10], value[3]
        else:
            return tweet_id, value[2], value[4], "Não arquivado", value[3]
    else:
        return 0, "", "", "Não arquivado", ""
コード例 #19
0
ファイル: database.py プロジェクト: lagolucas/twitter-mimic
def insere_lista(tweets):
    db = database_auth.conecta_banco()
    for tweet in tweets:
        insere_um(tweet, db)
    db.commit()
    db.close()