diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 6ac28bd1..2677d11b 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -157,15 +157,12 @@ def prepareBulkImport(fdb): pass elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! - print "Index dropping disabled for postgresql." -# print "dropping pg fk", fk['fktab'], fk['fkcol'] -# try: -# fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') -# print "alter table " + fk['fktab'] + " drop constraint " \ -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' -# except: -# pass + print "dropping pg fk", fk['fktab'], fk['fkcol'] + try: + fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " + + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') + except: + pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -181,15 +178,14 @@ def prepareBulkImport(fdb): elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! print "Index dropping disabled for postgresql." -# print "dropping pg index ", idx['tab'], idx['col'] -# # mod to use tab_col for index name? -# try: -# pass -# print "drop index %s_%s_idx" % (idx['tab'],idx['col']) -# fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) ) -# print "dropped pg index ", idx['tab'], idx['col'] -# except: -# pass + print "dropping pg index ", idx['tab'], idx['col'] + # mod to use tab_col for index name? + try: + print "drop index %s_%s_idx" % (idx['tab'],idx['col']) + fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) ) + print "dropped pg index ", idx['tab'], idx['col'] + except: + pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -228,19 +224,14 @@ def afterBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - pass -# print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] -# try: -# print "alter table " + fk['fktab'] + " add constraint " \ -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' \ -# + " foreign key (" + fk['fkcol'] \ -# + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")" -# fdb.cursor.execute("alter table " + fk['fktab'] + " add constraint " -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' -# + " foreign key (" + fk['fkcol'] -# + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") -# except: -# pass + print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] + try: + fdb.cursor.execute("alter table " + fk['fktab'] + " add constraint " + + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' + + " foreign key (" + fk['fkcol'] + + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") + except: + pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -255,16 +246,16 @@ def afterBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - pass -# # mod to use tab_col for index name? -# print "creating pg index ", idx['tab'], idx['col'] -# try: -# print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) -# fdb.cursor.execute( "create index %s_%s_idx on %s(%s)" -# % (idx['tab'], idx['col'], idx['tab'], idx['col']) ) -# except: -# print " ERROR! :-(" -# pass +# pass + # mod to use tab_col for index name? + print "creating pg index ", idx['tab'], idx['col'] + try: + print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) + fdb.cursor.execute( "create index %s_%s_idx on %s(%s)" + % (idx['tab'], idx['col'], idx['tab'], idx['col']) ) + except: + print " ERROR! :-(" + pass else: print "Only MySQL and Postgres supported so far" return -1