wcp-library 1.0.6__py3-none-any.whl → 1.0.8__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.
@@ -32,8 +32,7 @@ async def connect_warehouse(username: str, password: str, hostname: str, port: i
32
32
  dsn=dsn,
33
33
  min=min_connections,
34
34
  max=max_connections,
35
- increment=1,
36
- encoding="UTF-8"
35
+ increment=1
37
36
  )
38
37
  return session_pool
39
38
 
@@ -113,11 +112,10 @@ class AsyncOracleConnection(object):
113
112
  :return: None
114
113
  """
115
114
 
116
- connection = self._session_pool.acquire()
117
- cursor = connection.cursor()
118
- await cursor.execute(query)
119
- await connection.commit()
120
- await self._session_pool.release(connection)
115
+ async with self._session_pool.acquire() as connection:
116
+ with connection.cursor() as cursor:
117
+ await cursor.execute(query)
118
+ await connection.commit()
121
119
 
122
120
  @retry
123
121
  async def safe_execute(self, query: str, packed_values: dict) -> None:
@@ -129,11 +127,10 @@ class AsyncOracleConnection(object):
129
127
  :return: None
130
128
  """
131
129
 
132
- connection = self._session_pool.acquire()
133
- cursor = connection.cursor()
134
- await cursor.execute(query, packed_values)
135
- await connection.commit()
136
- await self._session_pool.release(connection)
130
+ async with self._session_pool.acquire() as connection:
131
+ with connection.cursor() as cursor:
132
+ await cursor.execute(query, packed_values)
133
+ await connection.commit()
137
134
 
138
135
  @retry
139
136
  async def execute_multiple(self, queries: list[list[str, dict]]) -> None:
@@ -144,17 +141,16 @@ class AsyncOracleConnection(object):
144
141
  :return: None
145
142
  """
146
143
 
147
- connection = self._session_pool.acquire()
148
- cursor = connection.cursor()
149
- for item in queries:
150
- query = item[0]
151
- packed_values = item[1]
152
- if packed_values:
153
- await cursor.execute(query, packed_values)
154
- else:
155
- await cursor.execute(query)
156
- await connection.commit()
157
- await self._session_pool.release(connection)
144
+ async with self._session_pool.acquire() as connection:
145
+ with connection.cursor() as cursor:
146
+ for item in queries:
147
+ query = item[0]
148
+ packed_values = item[1]
149
+ if packed_values:
150
+ await cursor.execute(query, packed_values)
151
+ else:
152
+ await cursor.execute(query)
153
+ await connection.commit()
158
154
 
159
155
  @retry
160
156
  async def execute_many(self, query: str, dictionary: list[dict]) -> None:
@@ -166,11 +162,10 @@ class AsyncOracleConnection(object):
166
162
  :return: None
167
163
  """
168
164
 
169
- connection = self._session_pool.acquire()
170
- cursor = connection.cursor()
171
- await cursor.executemany(query, dictionary)
172
- await connection.commit()
173
- await self._session_pool.release(connection)
165
+ async with self._session_pool.acquire() as connection:
166
+ with connection.cursor() as cursor:
167
+ await cursor.executemany(query, dictionary)
168
+ await connection.commit()
174
169
 
175
170
  @retry
176
171
  async def fetch_data(self, query: str, packed_data=None):
@@ -182,14 +177,13 @@ class AsyncOracleConnection(object):
182
177
  :return: rows
183
178
  """
184
179
 
185
- connection = self._session_pool.acquire()
186
- cursor = connection.cursor()
187
- if packed_data:
188
- await cursor.execute(query, packed_data)
189
- else:
190
- await cursor.execute(query)
191
- rows = cursor.fetchall()
192
- await self._session_pool.release(connection)
180
+ async with self._session_pool.acquire() as connection:
181
+ with connection.cursor() as cursor:
182
+ if packed_data:
183
+ await cursor.execute(query, packed_data)
184
+ else:
185
+ await cursor.execute(query)
186
+ rows = cursor.fetchall()
193
187
  return rows
194
188
 
195
189
  @retry
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.0.6
3
+ Version: 1.0.8
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Home-page: https://github.com/Whitecap-DNA/WCP-Library
6
6
  Author: Mitch-Petersen
@@ -4,7 +4,7 @@ wcp_library/async_credentials/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
4
4
  wcp_library/async_credentials/oracle.py,sha256=MvC7wsHnSyAyPGnRVlH0dvvW2xk5ap_IAByoHX4rUWY,5436
5
5
  wcp_library/async_credentials/postgres.py,sha256=3wjqtLH0Nc-U80iscYnz5DV-9M2X4IjPW51C5MI2_tI,5297
6
6
  wcp_library/async_sql/__init__.py,sha256=m4eWmUGYUEDomhhOp1ScB2uSIXFsNUNO589o5RwWdyM,1035
7
- wcp_library/async_sql/oracle.py,sha256=cqEWyCgyvAD0gwMUlXOhnW2hI02IPJfjwyyhs06pri8,7411
7
+ wcp_library/async_sql/oracle.py,sha256=XBGE6PPzZbLcHBJghxu3rkK9ZZ5Fp42Sm0-ZWSpzsWA,7392
8
8
  wcp_library/async_sql/postgres.py,sha256=7ehET1l42gKnsOcqeWLcXBEdYfvvA1qVfdG0QJv57Vk,6593
9
9
  wcp_library/credentials/__init__.py,sha256=HRmg7mqcATeclIz3lZQjSR4nmK6aY6MK9-QXEYZoFrw,1857
10
10
  wcp_library/credentials/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -16,6 +16,6 @@ wcp_library/logging.py,sha256=h8p_Ezo_QPSIKrPxzIlNVXddU4IXHyp1_2NqVDirfuk,1958
16
16
  wcp_library/sql/__init__.py,sha256=CLlBEBrWVAwE79bUxuQiwikSrYH8m9QRYSJ2l0-ofsY,1003
17
17
  wcp_library/sql/oracle.py,sha256=ur91kgds11M7xiGlDNkodxu2P7M-crqK0toYJcOHgdo,7285
18
18
  wcp_library/sql/postgres.py,sha256=hIw9ckxV_iRqZA0rSCMmbG82iil8mY4g-ajtHYVIq3I,6492
19
- wcp_library-1.0.6.dist-info/METADATA,sha256=c0TbPZ1rbmadB7lQ2Jdc2tR-7b7bPjkRMrsgfkUISaE,1338
20
- wcp_library-1.0.6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
21
- wcp_library-1.0.6.dist-info/RECORD,,
19
+ wcp_library-1.0.8.dist-info/METADATA,sha256=8p_UNTEOGEJgW_Sro62or-pXb2Z2DGjJOKf5wow8U4Q,1338
20
+ wcp_library-1.0.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
21
+ wcp_library-1.0.8.dist-info/RECORD,,