mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 10:31:02 +02:00
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:
parent
a062db184d
commit
4e5fec95e3
@ -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):
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user