def BuildTables(database_namespace): TableA = Table(database_namespace, "Table2A") TableA.AddCol("PKcol_TabA") TableA.AddCol("Data_Column") TableA.AddPK("PKcol_TabA") if TableA.VerifyFKrefsCompletePK( ): # In SQL mode, this will create the table if _DB_mode == "AS": print(TableA.TableName, "has complete FK to PK references (or none exist in table)") else: print(TableA.TableName, "has been created in the SQL database") TableB = Table(database_namespace, "Table2B") TableB.AddCol("PKcol_TabB") TableB.AddCol("FK_BtoA") TableB.AddCol("Data_Column") TableB.AddPK("PKcol_TabB") TableB.AddPK( "FK_BtoA" ) # *** This is the only difference between Schema 1 and Schema 2 TableB.AddFK("FK_BtoA", "Table2A", "PKcol_TabA") if TableB.VerifyFKrefsCompletePK(): if _DB_mode == "AS": print(TableB.TableName, "has complete FK to PK references (or none exist in table)") else: print(TableB.TableName, "has been created in the SQL database")
def BuildTables( database_namespace ): # TODO Verify this is the schema we want. Noticed old DB name was SEF and not SQL like the others TableA = Table(database_namespace, "Table3A") TableA.AddCol("PKcol_TabA") TableA.AddCol("DataColA") TableA.AddPK("PKcol_TabA") if TableA.VerifyFKrefsCompletePK( ): # In SQL mode, this will create the table if _DB_mode == "AS": print(TableA.TableName, "has complete FK to PK references (or none exist in table)") else: print(TableA.TableName, "has been created in the SQL database") TableB = Table(database_namespace, "Table3B") TableB.AddCol("PKcol_TabB") TableB.AddCol("DataColB") TableB.AddPK("PKcol_TabB") if TableB.VerifyFKrefsCompletePK(): if _DB_mode == "AS": print(TableB.TableName, "has complete FK to PK references (or none exist in table)") else: print(TableB.TableName, "has been created in the SQL database") TableC = Table(database_namespace, "Table3C") TableC.AddCol("FK_CtoA") TableC.AddCol("FK_CtoB") TableC.AddCol("PKcol_TabC") TableC.AddCol("DataColC") TableC.AddPK("FK_CtoA") TableC.AddPK("FK_CtoB") TableC.AddPK("PKcol_TabC") TableC.AddFK("FK_CtoA", "Table3A", "PKcol_TabA") TableC.AddFK("FK_CtoB", "Table3B", "PKcol_TabB") if TableC.VerifyFKrefsCompletePK(): if _DB_mode == "AS": print(TableC.TableName, "has complete FK to PK references (or none exist in table)") else: print(TableC.TableName, "has been created in the SQL database")
for tableName in recordedTimes: csv_list = [ _DB_mode, _SchemaNumber, operation, tableName, NumberRows, FKreptFactor, constraints ] csv_list.append(statistics.mean(recordedTimes[tableName])) csv_list.append(statistics.median(recordedTimes[tableName])) csv_list.append(statistics.stdev(recordedTimes[tableName])) # Now append a timestamp csv_list.append( str("{:%Y-%m-%d_%H%M%S}".format(datetime.datetime.now()))) csvdata.log_csv2file(csv_list) return Table.SetDebugMode(False) Table.GetDebugMode() # ***Open communication with the database*** if _DB_mode == "AS": # Specify the IP addresses and ports for the Aerospike cluster config = {'hosts': [('18.222.211.167', 3000), ('3.16.180.184', 3000)]} # Create a client and connect it to the cluster print("RunActualDB is", RunActualDB) print("Benchmarking with AeroSpike, Schema 2") database = "test_DB_SEF" try: client = aerospike.client(config).connect() #Be sure to tell the Table class the name of the client it's talking to Table.SetTableClient(client) except:
B_Row.append(row_seq[idx]) #The PK for Table B t0 = time.time() TableB.Delete(B_Row) t1 = time.time() B_times.append((t1 - t0) * 1000) # Times are in S so *1000 makes units mS t0 = time.time() TableA.Delete(A_Row) t1 = time.time() A_times.append((t1 - t0) * 1000) # Times are in S so *1000 makes units mS All_times["Table1A"] = A_times All_times["Table1B"] = B_times return(All_times) Table.SetDebugMode(False) Table.GetDebugMode() # ***Open communication with the database*** if sys.argv[1] == "AS": # Specify the IP addresses and ports for the Aerospike cluster config = { 'hosts': [ ('18.222.211.167', 3000), ('3.16.180.184', 3000) ] } # Create a client and connect it to the cluster print("RunActualDB is", RunActualDB) print("Benchmarking with AeroSpike, Schema 1") database="test_DB_SEF" try: client = aerospike.client(config).connect() #Be sure to tell the Table class the name of the client it's talking to