wcp-library 1.5.8__py3-none-any.whl → 1.6.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wcp_library/sql/postgres.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import logging
|
2
|
-
from
|
3
|
-
from typing import Optional, Any
|
2
|
+
from typing import Optional
|
4
3
|
|
5
4
|
import numpy as np
|
6
5
|
import pandas as pd
|
@@ -128,7 +127,7 @@ class PostgresConnection(object):
|
|
128
127
|
else:
|
129
128
|
self._connection = self.connection
|
130
129
|
|
131
|
-
def _get_connection(self) ->
|
130
|
+
def _get_connection(self) -> Connection:
|
132
131
|
"""
|
133
132
|
Get the connection object
|
134
133
|
|
@@ -136,7 +135,7 @@ class PostgresConnection(object):
|
|
136
135
|
"""
|
137
136
|
|
138
137
|
if self.use_pool:
|
139
|
-
connection = self._session_pool.
|
138
|
+
connection = self._session_pool.getconn()
|
140
139
|
return connection
|
141
140
|
else:
|
142
141
|
if self._connection is None or self._connection.closed:
|
@@ -186,6 +185,9 @@ class PostgresConnection(object):
|
|
186
185
|
with connection:
|
187
186
|
connection.execute(query)
|
188
187
|
|
188
|
+
if self.use_pool:
|
189
|
+
self._session_pool.putconn(connection)
|
190
|
+
|
189
191
|
@retry
|
190
192
|
def safe_execute(self, query: SQL | str, packed_values: dict) -> None:
|
191
193
|
"""
|
@@ -200,6 +202,9 @@ class PostgresConnection(object):
|
|
200
202
|
with connection:
|
201
203
|
connection.execute(query, packed_values)
|
202
204
|
|
205
|
+
if self.use_pool:
|
206
|
+
self._session_pool.putconn(connection)
|
207
|
+
|
203
208
|
@retry
|
204
209
|
def execute_multiple(self, queries: list[tuple[SQL | str, dict]]) -> None:
|
205
210
|
"""
|
@@ -219,6 +224,9 @@ class PostgresConnection(object):
|
|
219
224
|
else:
|
220
225
|
connection.execute(query)
|
221
226
|
|
227
|
+
if self.use_pool:
|
228
|
+
self._session_pool.putconn(connection)
|
229
|
+
|
222
230
|
@retry
|
223
231
|
def execute_many(self, query: SQL | str, dictionary: list[dict]) -> None:
|
224
232
|
"""
|
@@ -234,6 +242,9 @@ class PostgresConnection(object):
|
|
234
242
|
cursor = connection.cursor()
|
235
243
|
cursor.executemany(query, dictionary)
|
236
244
|
|
245
|
+
if self.use_pool:
|
246
|
+
self._session_pool.putconn(connection)
|
247
|
+
|
237
248
|
@retry
|
238
249
|
def fetch_data(self, query: SQL | str, packed_data=None) -> list[tuple]:
|
239
250
|
"""
|
@@ -252,6 +263,9 @@ class PostgresConnection(object):
|
|
252
263
|
else:
|
253
264
|
cursor.execute(query)
|
254
265
|
rows = cursor.fetchall()
|
266
|
+
|
267
|
+
if self.use_pool:
|
268
|
+
self._session_pool.putconn(connection)
|
255
269
|
return rows
|
256
270
|
|
257
271
|
@retry
|
@@ -18,8 +18,8 @@ wcp_library/selenium/_selenium_driver.py,sha256=Es83ISNryOVhYGDo_xrr8nCLsbnVBeXs
|
|
18
18
|
wcp_library/selenium/selenium_helper.py,sha256=OJvC0RlblfMWhmjNxiY582yuzkDgjzFZMuRz_8to3PY,2000
|
19
19
|
wcp_library/sql/__init__.py,sha256=f0JyVyFyUjueQ1XdVmCgmRjzkFENmFKl3BOzrvv3i1I,2422
|
20
20
|
wcp_library/sql/oracle.py,sha256=L2UG-0jQNYSvTy9OAxRjWLIEIpfbLrIXeddYfuC3ipA,18812
|
21
|
-
wcp_library/sql/postgres.py,sha256=
|
21
|
+
wcp_library/sql/postgres.py,sha256=I6Mw7QnXHu-aIOe8CiLcqgJ8wNzyjrTy3_bhfEV-2pI,18631
|
22
22
|
wcp_library/time.py,sha256=ktSzhK7SZnGPNXobFexnhFGQAcriLCJQKxnO0fed8fQ,1740
|
23
|
-
wcp_library-1.
|
24
|
-
wcp_library-1.
|
25
|
-
wcp_library-1.
|
23
|
+
wcp_library-1.6.1.dist-info/METADATA,sha256=POlu-hZub7JLGST9pp2bS4wv4YQGgi2PbAMT76kJXUE,1393
|
24
|
+
wcp_library-1.6.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
25
|
+
wcp_library-1.6.1.dist-info/RECORD,,
|
File without changes
|