Ejemplo n.º 1
0
     try:
         dbc.execute(queries.ClearRecordsTable)
         dbc.execute(queries.ClearAthletesTable)
         dbc.execute(queries.CLEAR_TRAINERS_TABLE)
         with open(file, newline='') as f:
             dbc.executemany(
                 queries.addRecordFromFile,
                 InputDataSet(f).check_rec_format().get_data_per_row())
             dbc.execute(queries.FillInAthletesTable)
             dbc.execute(queries.AddAthleteIdToStatRecord)
             dbc.execute(queries.FILL_IN_TRAINERS_TABLE)
     except Connection.Error as e:
         # print(dbc._last_executed)
         print("MySQL Error {0}: {1}".format(e.args[0], e.args[1]))
     else:
         db.commit()
 elif o in ("-d", ):
     q_object = get_duplicate_name()
     SelectResult(q_object).print_qresult()
 elif o in ("--by-name"):
     q_object = get_regdata_by_name(a)
     result = SelectResult(q_object).print_qresult().report_tofile(
         "duplicates.csv")
 elif o in ("--schools"):
     try:
         dbc.execute(queries.GET_SCHOOLS)
         SelectResult(dbc).print_qresult()
     except Connection.Error as e:
         print("MySQL Error {0}: {1}".format(e.args[0], e.args[1]))
 else:
     assert False, "unhandled option"
Ejemplo n.º 2
0
 def _critical_commit(self):
     try:
         BaseConnection.commit(self)
     finally:
         self.exit_critical_phase_at_transaction_end()