Fix connection management bug when columns = *.

Instead of opening a connection per section and leaving it open until the
end for the run, open a connection just for getting this section columns
then close it. Per gripes from a user dealing with 90000 sections.
This commit is contained in:
Dimitri Fontaine 2010-04-29 17:14:44 +02:00
parent a062db184d
commit 4e5fec95e3
2 changed files with 10 additions and 3 deletions

View File

@ -148,7 +148,12 @@ ORDER BY attnum
"""
self.log.debug("get_all_columns: %s %s %s" % (tablename, schemaname, sql))
columns = []
columns = []
have_to_connect = self.dbconn is None
if have_to_connect:
self.reset()
cursor = self.dbconn.cursor()
try:
cursor.execute(sql, [tablename, schemaname])
@ -161,6 +166,9 @@ ORDER BY attnum
cursor.close()
if have_to_connect:
self.close()
return columns
def reset(self):

View File

@ -314,8 +314,7 @@ class PGLoader(threading.Thread):
self.all_cols = True
self.db.all_cols = True
# force db to connect now
self.db.reset()
# get column list from database
self.columns = self.db.get_all_columns(self.table)
self.log.info("columns = *, got %s", str(self.columns))