Beispiel #1
0
def main(sqlite_file, server_person_id):
    (db_mysql, cur_mysql) = dbs.connect_mysql()
    (db_sqlite, cur_sqlite) = dbs.connect_sqlite(sqlite_file)

    sqlite_tables = dbs.get_name_of_tables_sqlite(cur_sqlite)

    for table in sqlite_tables:
        results = cur_sqlite.execute("SELECT * FROM " + table)

        for row in results.fetchall():
            insert = "INSERT INTO " + table + " VALUES( " + server_person_id + ", "
            str_row = []
            for r in row:
                # TODO: fix, handle unicode characters
                if type(r) == unicode:
                    r = r.encode('ascii', 'ignore')
                r = str(r).replace("'", '')
                str_row.append("'" + r + "'")

            insert += ",".join(str_row)

            insert += ")"

            cur_mysql.execute(insert)

    db_mysql.commit()
def main():
    (db_mysql, cur_mysql) = dbs.connect_mysql()
    (db_sqlite, cur_sqlite) = dbs.connect_sqlite()

    drop_chronojump_table(db_mysql, cur_mysql)
    (db_mysql, cur_mysql) = dbs.connect_mysql()

    # Creates tables
    table_names = dbs.get_name_of_tables_sqlite(cur_sqlite)

    for table_name in table_names:
        sql_table = dbs.get_create_table(cur_sqlite, table_name)
        sql_table = add_person_id(sql_table)

        sql_table = fix_unique_id_primary_key(sql_table)

        cur_mysql.execute(sql_table)