Skip to content

Commit 723e1fa

Browse files
committed
test: Fix FATAL: sorry, too many clients already
Dispose the SQLAlchemy engine object after use within `PostgresConnector`.
1 parent a9d1796 commit 723e1fa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

target_postgres/connector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ def copy_table_structure(
180180

181181
@contextmanager
182182
def _connect(self) -> t.Iterator[sqlalchemy.engine.Connection]:
183-
with self._engine.connect().execution_options() as conn:
183+
engine = self._engine
184+
with engine.connect().execution_options() as conn:
184185
yield conn
186+
engine.dispose()
185187

186188
def drop_table(
187189
self, table: sqlalchemy.Table, connection: sqlalchemy.engine.Connection

0 commit comments

Comments
 (0)