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")
TableA.AddCol("Data_Column") TableA.AddPK("PKcol1") TableA.AddPK("PKcol2") if TableA.VerifyFKrefsCompletePK(): # This should pass 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, "Table4B") TableB.AddCol("PKcol1") TableB.AddCol("FK1_BtoA") TableB.AddCol("FK2_BtoA") TableB.AddCol("Data_Column") TableB.AddPK("PKcol1") TableB.AddFK("FK1_BtoA", "Table4A", "PKcol1") TableB.AddFK("FK2_BtoA", "Table4A", "PKcol2") if TableB.VerifyFKrefsCompletePK(): # This should pass since FK refs complete PK 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, "Table4C") TableC.AddCol("PKcol1") TableC.AddCol("FK1_CtoA") TableC.AddCol("Data_Column") TableC.AddPK("PKcol1") TableC.AddFK("FK1_CtoA", "Table4A", "PKcol1")