psql drop fk hang: seemed to be caused by having more than one
connection to the db open. Made GuiBulkImport use the importer's connection instead of its own. It still has the one given to it by fpdb.py. I really don't know. Perhaps it needed a commit.
This commit is contained in:
parent
411715c44d
commit
3f879ddb3d
|
@ -197,8 +197,8 @@ class GuiBulkImport():
|
||||||
self.load_button.show()
|
self.load_button.show()
|
||||||
|
|
||||||
# see how many hands are in the db and adjust accordingly
|
# see how many hands are in the db and adjust accordingly
|
||||||
tcursor = db.db.cursor()
|
tcursor = self.importer.fdb.db.cursor()
|
||||||
tcursor.execute("Select count(1) from Hands;")
|
tcursor.execute("Select count(1) from Hands")
|
||||||
row = tcursor.fetchone()
|
row = tcursor.fetchone()
|
||||||
tcursor.close()
|
tcursor.close()
|
||||||
self.n_hands_in_db = row[0]
|
self.n_hands_in_db = row[0]
|
||||||
|
@ -233,7 +233,7 @@ def main(argv=None):
|
||||||
(options, sys.argv) = parser.parse_args(args = argv)
|
(options, sys.argv) = parser.parse_args(args = argv)
|
||||||
|
|
||||||
config = Configuration.Config()
|
config = Configuration.Config()
|
||||||
db = fpdb_db.fpdb_db()
|
db = None
|
||||||
|
|
||||||
settings = {}
|
settings = {}
|
||||||
settings['minPrint'] = options.minPrint
|
settings['minPrint'] = options.minPrint
|
||||||
|
|
|
@ -178,7 +178,6 @@ class Importer:
|
||||||
tmpcursor = self.fdb.db.cursor()
|
tmpcursor = self.fdb.db.cursor()
|
||||||
tmpcursor.execute("Select count(1) from Hands;")
|
tmpcursor.execute("Select count(1) from Hands;")
|
||||||
self.settings['handsInDB'] = tmpcursor.fetchone()[0]
|
self.settings['handsInDB'] = tmpcursor.fetchone()[0]
|
||||||
tmpcursor.close()
|
|
||||||
except:
|
except:
|
||||||
pass # if this fails we're probably doomed anyway
|
pass # if this fails we're probably doomed anyway
|
||||||
if self.settings['handsInDB'] < 5000: return "drop"
|
if self.settings['handsInDB'] < 5000: return "drop"
|
||||||
|
|
|
@ -53,7 +53,7 @@ indexes = [
|
||||||
, [ # indexes for postgres (list index 3)
|
, [ # indexes for postgres (list index 3)
|
||||||
{'tab':'Boardcards', 'col':'handId', 'drop':0}
|
{'tab':'Boardcards', 'col':'handId', 'drop':0}
|
||||||
, {'tab':'Gametypes', 'col':'siteId', 'drop':0}
|
, {'tab':'Gametypes', 'col':'siteId', 'drop':0}
|
||||||
, {'tab':'Hands', 'col':'gametypeId', 'drop':1}
|
, {'tab':'Hands', 'col':'gametypeId', 'drop':1} # todo :1 by sqlcoder , but this is needed for all duplicate checks. test 0
|
||||||
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
|
, {'tab':'Hands', 'col':'siteHandNo', 'drop':0}
|
||||||
, {'tab':'HandsActions', 'col':'handplayerId', 'drop':0}
|
, {'tab':'HandsActions', 'col':'handplayerId', 'drop':0}
|
||||||
, {'tab':'HandsPlayers', 'col':'handId', 'drop':1}
|
, {'tab':'HandsPlayers', 'col':'handId', 'drop':1}
|
||||||
|
@ -164,8 +164,8 @@ def prepareBulkImport(fdb):
|
||||||
# DON'T FORGET TO RECREATE THEM!!
|
# DON'T FORGET TO RECREATE THEM!!
|
||||||
#print "dropping pg fk", fk['fktab'], fk['fkcol']
|
#print "dropping pg fk", fk['fktab'], fk['fkcol']
|
||||||
try:
|
try:
|
||||||
fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint "
|
#print "alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol'])
|
||||||
+ fk['fktab'] + '_' + fk['fkcol'] + '_fkey')
|
fdb.cursor.execute("alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol']))
|
||||||
print "dropped pg fk pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol'])
|
print "dropped pg fk pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol'])
|
||||||
except:
|
except:
|
||||||
print "! failed drop pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol'])
|
print "! failed drop pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol'])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user