Ejemplo n.º 1
0
def create_table():
    with sclsql.cursor("ktp_incoming_data", **sclsql.hosts("scls1")) as cursor:
        cursor.execute("DROP TABLE IF EXISTS form_matches")
        cursor.execute("""
        CREATE TABLE form_matches(
        Form_Id INT(11) PRIMARY KEY,
        State VARCHAR(2),
        State_Voter_Id BIGINT(20),
        Entry_Date DATE,
        First_Name VARCHAR(64),
        Last_Name VARCHAR(64),
        Email VARCHAR(256),
        UNIQUE KEY (State, State_Voter_Id)
        )""")
Ejemplo n.º 2
0
def integrate(matched_persons):
    rows = []
    for form_person, dbperson in matched_persons:
        if dbperson is None:
            state, voter_id = None, None
        else:
            state, voter_id = dbperson.state, dbperson.voter_id
        row = (form_person.entry_id, state, voter_id, 
                form_person.date, form_person.first, form_person.last, 
                form_person.email)
        rows.append(row)
    with sclsql.cursor("ktp_incoming_data", **sclsql.hosts("scls1")) as cursor:
        cursor.executemany("""
        INSERT INTO form_matches 
        (Form_Id, State, State_Voter_Id, Entry_Date, First_Name, Last_Name, Email)
        VALUES (%s, %s, %s, %s, %s, %s, %s)
        """, rows)
Ejemplo n.º 3
0
def load_db_data():
    with sclsql.cursor("ktp_incoming_data", **sclsql.hosts("scls1")) as cursor:
        ia_persons = fetch_persons_from_table("list_IA_all_issues_ev", "IA", cursor)
        sc_persons = fetch_persons_from_table("list_SC_all_issues_ev", "SC", cursor)
    return ia_persons + sc_persons