#!/usr/bin/env python3 import util.script as script import mysql.connector from util.kSAT import kSAT def main(): edb = script.connect_to_experimetns_db("database.config") idb = script.connect_to_instance_pool("database.config")["experiments"] cursor = edb.cursor() insert_row = ("INSERT INTO degree_of_variables " "(instance, variable, degree) " "VALUES (%s, %s, %s)") for instance in idb["instances"].find(): sat = kSAT() for clause in instance["clauses"]: sat.addClause(clause) for variable, degree in sat.getDegreesOfVariables().items(): cursor.execute(insert_row, (str(instance["_id"]), variable, degree)) edb.commit() cursor.close() edb.close() if __name__ == "__main__": main()