Skip to content

Commit

Permalink
test: Fix FATAL: sorry, too many clients already
Browse files Browse the repository at this point in the history
Dispose the SQLAlchemy engine object after use within
`PostgresConnector`.
  • Loading branch information
amotl committed Dec 19, 2023
1 parent a9d1796 commit 723e1fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion target_postgres/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ def copy_table_structure(

@contextmanager
def _connect(self) -> t.Iterator[sqlalchemy.engine.Connection]:
with self._engine.connect().execution_options() as conn:
engine = self._engine
with engine.connect().execution_options() as conn:
yield conn
engine.dispose()

def drop_table(
self, table: sqlalchemy.Table, connection: sqlalchemy.engine.Connection
Expand Down

0 comments on commit 723e1fa

Please sign in to comment.