wcp-library 1.5.8__tar.gz → 1.6.2__tar.gz
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-1.5.8 → wcp_library-1.6.2}/PKG-INFO +1 -1
- {wcp_library-1.5.8 → wcp_library-1.6.2}/pyproject.toml +1 -1
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/sql/oracle.py +88 -66
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/sql/postgres.py +62 -48
- {wcp_library-1.5.8 → wcp_library-1.6.2}/README.md +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/__init__.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/__init__.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/_credential_manager_asynchronous.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/_credential_manager_synchronous.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/api.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/ftp.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/internet.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/oracle.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/postgres.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/emailing.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/ftp/__init__.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/ftp/ftp.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/ftp/sftp.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/informatica.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/logging.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/selenium/__init__.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/selenium/_selenium_driver.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/selenium/selenium_helper.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/sql/__init__.py +0 -0
- {wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/time.py +0 -0
@@ -191,10 +191,12 @@ class OracleConnection(object):
|
|
191
191
|
"""
|
192
192
|
|
193
193
|
connection = self._get_connection()
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
194
|
+
cursor = connection.cursor()
|
195
|
+
cursor.execute(query)
|
196
|
+
connection.commit()
|
197
|
+
|
198
|
+
if self.use_pool:
|
199
|
+
self._session_pool.release(self._connection)
|
198
200
|
|
199
201
|
@retry
|
200
202
|
def safe_execute(self, query: str, packed_values: dict) -> None:
|
@@ -207,10 +209,12 @@ class OracleConnection(object):
|
|
207
209
|
"""
|
208
210
|
|
209
211
|
connection = self._get_connection()
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
212
|
+
cursor = connection.cursor()
|
213
|
+
cursor.execute(query, packed_values)
|
214
|
+
connection.commit()
|
215
|
+
|
216
|
+
if self.use_pool:
|
217
|
+
self._session_pool.release(self._connection)
|
214
218
|
|
215
219
|
@retry
|
216
220
|
def execute_multiple(self, queries: list[tuple[str, dict]]) -> None:
|
@@ -222,16 +226,18 @@ class OracleConnection(object):
|
|
222
226
|
"""
|
223
227
|
|
224
228
|
connection = self._get_connection()
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
229
|
+
cursor = connection.cursor()
|
230
|
+
for item in queries:
|
231
|
+
query = item[0]
|
232
|
+
packed_values = item[1]
|
233
|
+
if packed_values:
|
234
|
+
cursor.execute(query, packed_values)
|
235
|
+
else:
|
236
|
+
cursor.execute(query)
|
237
|
+
connection.commit()
|
238
|
+
|
239
|
+
if self.use_pool:
|
240
|
+
self._session_pool.release(self._connection)
|
235
241
|
|
236
242
|
@retry
|
237
243
|
def execute_many(self, query: str, dictionary: list[dict]) -> None:
|
@@ -244,10 +250,12 @@ class OracleConnection(object):
|
|
244
250
|
"""
|
245
251
|
|
246
252
|
connection = self._get_connection()
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
253
|
+
cursor = connection.cursor()
|
254
|
+
cursor.executemany(query, dictionary)
|
255
|
+
connection.commit()
|
256
|
+
|
257
|
+
if self.use_pool:
|
258
|
+
self._session_pool.release(self._connection)
|
251
259
|
|
252
260
|
@retry
|
253
261
|
def fetch_data(self, query: str, packed_data=None) -> list:
|
@@ -260,13 +268,16 @@ class OracleConnection(object):
|
|
260
268
|
"""
|
261
269
|
|
262
270
|
connection = self._get_connection()
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
271
|
+
cursor = connection.cursor()
|
272
|
+
if packed_data:
|
273
|
+
cursor.execute(query, packed_data)
|
274
|
+
else:
|
275
|
+
cursor.execute(query)
|
276
|
+
rows = cursor.fetchall()
|
277
|
+
connection.commit()
|
278
|
+
|
279
|
+
if self.use_pool:
|
280
|
+
self._session_pool.release(self._connection)
|
270
281
|
return rows
|
271
282
|
|
272
283
|
@retry
|
@@ -290,7 +301,7 @@ class OracleConnection(object):
|
|
290
301
|
params = param_list[0]
|
291
302
|
|
292
303
|
main_dict = df.to_dict('records')
|
293
|
-
query = f"
|
304
|
+
query = f"DELETE FROM {outputTableName} WHERE {params}"
|
294
305
|
self.execute_many(query, main_dict)
|
295
306
|
|
296
307
|
@retry
|
@@ -315,7 +326,7 @@ class OracleConnection(object):
|
|
315
326
|
dfObj = dfObj.replace({np.nan: None})
|
316
327
|
main_dict = dfObj.to_dict('records')
|
317
328
|
|
318
|
-
query = f"
|
329
|
+
query = f"INSERT INTO {outputTableName} ({col}) VALUES ({bind})"
|
319
330
|
self.execute_many(query, main_dict)
|
320
331
|
|
321
332
|
@retry
|
@@ -327,7 +338,7 @@ class OracleConnection(object):
|
|
327
338
|
:return: None
|
328
339
|
"""
|
329
340
|
|
330
|
-
truncateQuery = f"
|
341
|
+
truncateQuery = f"TRUNCATE TABLE {tableName}"
|
331
342
|
self.execute(truncateQuery)
|
332
343
|
|
333
344
|
@retry
|
@@ -339,7 +350,7 @@ class OracleConnection(object):
|
|
339
350
|
:return: None
|
340
351
|
"""
|
341
352
|
|
342
|
-
deleteQuery = f"
|
353
|
+
deleteQuery = f"DELETE FROM {tableName}"
|
343
354
|
self.execute(deleteQuery)
|
344
355
|
|
345
356
|
def __del__(self) -> None:
|
@@ -460,10 +471,12 @@ class AsyncOracleConnection(object):
|
|
460
471
|
"""
|
461
472
|
|
462
473
|
connection = await self._get_connection()
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
474
|
+
with connection.cursor() as cursor:
|
475
|
+
await cursor.execute(query)
|
476
|
+
await connection.commit()
|
477
|
+
|
478
|
+
if self.use_pool:
|
479
|
+
await self._session_pool.release(self._connection)
|
467
480
|
|
468
481
|
@async_retry
|
469
482
|
async def safe_execute(self, query: str, packed_values: dict) -> None:
|
@@ -476,10 +489,12 @@ class AsyncOracleConnection(object):
|
|
476
489
|
"""
|
477
490
|
|
478
491
|
connection = await self._get_connection()
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
492
|
+
with connection.cursor() as cursor:
|
493
|
+
await cursor.execute(query, packed_values)
|
494
|
+
await connection.commit()
|
495
|
+
|
496
|
+
if self.use_pool:
|
497
|
+
await self._session_pool.release(self._connection)
|
483
498
|
|
484
499
|
@async_retry
|
485
500
|
async def execute_multiple(self, queries: list[tuple[str, dict]]) -> None:
|
@@ -491,16 +506,18 @@ class AsyncOracleConnection(object):
|
|
491
506
|
"""
|
492
507
|
|
493
508
|
connection = await self._get_connection()
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
509
|
+
with connection.cursor() as cursor:
|
510
|
+
for item in queries:
|
511
|
+
query = item[0]
|
512
|
+
packed_values = item[1]
|
513
|
+
if packed_values:
|
514
|
+
await cursor.execute(query, packed_values)
|
515
|
+
else:
|
516
|
+
await cursor.execute(query)
|
517
|
+
await connection.commit()
|
518
|
+
|
519
|
+
if self.use_pool:
|
520
|
+
await self._session_pool.release(self._connection)
|
504
521
|
|
505
522
|
@async_retry
|
506
523
|
async def execute_many(self, query: str, dictionary: list[dict]) -> None:
|
@@ -513,10 +530,12 @@ class AsyncOracleConnection(object):
|
|
513
530
|
"""
|
514
531
|
|
515
532
|
connection = await self._get_connection()
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
533
|
+
with connection.cursor() as cursor:
|
534
|
+
await cursor.executemany(query, dictionary)
|
535
|
+
await connection.commit()
|
536
|
+
|
537
|
+
if self.use_pool:
|
538
|
+
await self._session_pool.release(self._connection)
|
520
539
|
|
521
540
|
@async_retry
|
522
541
|
async def fetch_data(self, query: str, packed_data=None) -> list:
|
@@ -529,13 +548,16 @@ class AsyncOracleConnection(object):
|
|
529
548
|
"""
|
530
549
|
|
531
550
|
connection = await self._get_connection()
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
551
|
+
with connection.cursor() as cursor:
|
552
|
+
if packed_data:
|
553
|
+
await cursor.execute(query, packed_data)
|
554
|
+
else:
|
555
|
+
await cursor.execute(query)
|
556
|
+
rows = await cursor.fetchall()
|
557
|
+
await connection.commit()
|
558
|
+
|
559
|
+
if self.use_pool:
|
560
|
+
await self._session_pool.release(self._connection)
|
539
561
|
return rows
|
540
562
|
|
541
563
|
@async_retry
|
@@ -559,7 +581,7 @@ class AsyncOracleConnection(object):
|
|
559
581
|
params = param_list[0]
|
560
582
|
|
561
583
|
main_dict = df.to_dict('records')
|
562
|
-
query = f"
|
584
|
+
query = f"DELETE FROM {outputTableName} WHERE {params}"
|
563
585
|
await self.execute_many(query, main_dict)
|
564
586
|
|
565
587
|
@async_retry
|
@@ -584,7 +606,7 @@ class AsyncOracleConnection(object):
|
|
584
606
|
dfObj = dfObj.replace({np.nan: None})
|
585
607
|
main_dict = dfObj.to_dict('records')
|
586
608
|
|
587
|
-
query = f"
|
609
|
+
query = f"INSERT INTO {outputTableName} ({col}) VALUES ({bind})"
|
588
610
|
await self.execute_many(query, main_dict)
|
589
611
|
|
590
612
|
@async_retry
|
@@ -596,7 +618,7 @@ class AsyncOracleConnection(object):
|
|
596
618
|
:return: None
|
597
619
|
"""
|
598
620
|
|
599
|
-
truncateQuery = f"
|
621
|
+
truncateQuery = f"TRUNCATE TABLE {tableName}"
|
600
622
|
await self.execute(truncateQuery)
|
601
623
|
|
602
624
|
@async_retry
|
@@ -608,5 +630,5 @@ class AsyncOracleConnection(object):
|
|
608
630
|
:return: None
|
609
631
|
"""
|
610
632
|
|
611
|
-
deleteQuery = f"
|
633
|
+
deleteQuery = f"DELETE FROM {tableName}"
|
612
634
|
await self.execute(deleteQuery)
|
@@ -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:
|
@@ -183,8 +182,11 @@ class PostgresConnection(object):
|
|
183
182
|
"""
|
184
183
|
|
185
184
|
connection = self._get_connection()
|
186
|
-
|
187
|
-
|
185
|
+
connection.execute(query)
|
186
|
+
connection.commit()
|
187
|
+
|
188
|
+
if self.use_pool:
|
189
|
+
self._session_pool.putconn(connection)
|
188
190
|
|
189
191
|
@retry
|
190
192
|
def safe_execute(self, query: SQL | str, packed_values: dict) -> None:
|
@@ -197,8 +199,11 @@ class PostgresConnection(object):
|
|
197
199
|
"""
|
198
200
|
|
199
201
|
connection = self._get_connection()
|
200
|
-
|
201
|
-
|
202
|
+
connection.execute(query, packed_values)
|
203
|
+
connection.commit()
|
204
|
+
|
205
|
+
if self.use_pool:
|
206
|
+
self._session_pool.putconn(connection)
|
202
207
|
|
203
208
|
@retry
|
204
209
|
def execute_multiple(self, queries: list[tuple[SQL | str, dict]]) -> None:
|
@@ -210,14 +215,17 @@ class PostgresConnection(object):
|
|
210
215
|
"""
|
211
216
|
|
212
217
|
connection = self._get_connection()
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
for item in queries:
|
219
|
+
query = item[0]
|
220
|
+
packed_values = item[1]
|
221
|
+
if packed_values:
|
222
|
+
connection.execute(query, packed_values)
|
223
|
+
else:
|
224
|
+
connection.execute(query)
|
225
|
+
connection.commit()
|
226
|
+
|
227
|
+
if self.use_pool:
|
228
|
+
self._session_pool.putconn(connection)
|
221
229
|
|
222
230
|
@retry
|
223
231
|
def execute_many(self, query: SQL | str, dictionary: list[dict]) -> None:
|
@@ -230,9 +238,12 @@ class PostgresConnection(object):
|
|
230
238
|
"""
|
231
239
|
|
232
240
|
connection = self._get_connection()
|
233
|
-
|
234
|
-
|
235
|
-
|
241
|
+
cursor = connection.cursor()
|
242
|
+
cursor.executemany(query, dictionary)
|
243
|
+
connection.commit()
|
244
|
+
|
245
|
+
if self.use_pool:
|
246
|
+
self._session_pool.putconn(connection)
|
236
247
|
|
237
248
|
@retry
|
238
249
|
def fetch_data(self, query: SQL | str, packed_data=None) -> list[tuple]:
|
@@ -245,13 +256,16 @@ class PostgresConnection(object):
|
|
245
256
|
"""
|
246
257
|
|
247
258
|
connection = self._get_connection()
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
259
|
+
cursor = connection.cursor()
|
260
|
+
if packed_data:
|
261
|
+
cursor.execute(query, packed_data)
|
262
|
+
else:
|
263
|
+
cursor.execute(query)
|
264
|
+
rows = cursor.fetchall()
|
265
|
+
connection.commit()
|
266
|
+
|
267
|
+
if self.use_pool:
|
268
|
+
self._session_pool.putconn(connection)
|
255
269
|
return rows
|
256
270
|
|
257
271
|
@retry
|
@@ -443,8 +457,8 @@ class AsyncPostgresConnection(object):
|
|
443
457
|
"""
|
444
458
|
|
445
459
|
connection = await self._get_connection()
|
446
|
-
|
447
|
-
|
460
|
+
await connection.execute(query)
|
461
|
+
await connection.commit()
|
448
462
|
|
449
463
|
if self.use_pool:
|
450
464
|
await self._session_pool.putconn(connection)
|
@@ -460,8 +474,8 @@ class AsyncPostgresConnection(object):
|
|
460
474
|
"""
|
461
475
|
|
462
476
|
connection = await self._get_connection()
|
463
|
-
|
464
|
-
|
477
|
+
await connection.execute(query, packed_values)
|
478
|
+
await connection.commit()
|
465
479
|
|
466
480
|
if self.use_pool:
|
467
481
|
await self._session_pool.putconn(connection)
|
@@ -476,14 +490,14 @@ class AsyncPostgresConnection(object):
|
|
476
490
|
"""
|
477
491
|
|
478
492
|
connection = await self._get_connection()
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
493
|
+
for item in queries:
|
494
|
+
query = item[0]
|
495
|
+
packed_values = item[1]
|
496
|
+
if packed_values:
|
497
|
+
await connection.execute(query, packed_values)
|
498
|
+
else:
|
499
|
+
await connection.execute(query)
|
500
|
+
await connection.commit()
|
487
501
|
|
488
502
|
if self.use_pool:
|
489
503
|
await self._session_pool.putconn(connection)
|
@@ -499,9 +513,9 @@ class AsyncPostgresConnection(object):
|
|
499
513
|
"""
|
500
514
|
|
501
515
|
connection = await self._get_connection()
|
502
|
-
|
503
|
-
|
504
|
-
|
516
|
+
cursor = connection.cursor()
|
517
|
+
await cursor.executemany(query, dictionary)
|
518
|
+
await connection.commit()
|
505
519
|
|
506
520
|
if self.use_pool:
|
507
521
|
await self._session_pool.putconn(connection)
|
@@ -517,13 +531,13 @@ class AsyncPostgresConnection(object):
|
|
517
531
|
"""
|
518
532
|
|
519
533
|
connection = await self._get_connection()
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
534
|
+
cursor = connection.cursor()
|
535
|
+
if packed_data:
|
536
|
+
await cursor.execute(query, packed_data)
|
537
|
+
else:
|
538
|
+
await cursor.execute(query)
|
539
|
+
rows = await cursor.fetchall()
|
540
|
+
await connection.commit()
|
527
541
|
|
528
542
|
if self.use_pool:
|
529
543
|
await self._session_pool.putconn(connection)
|
File without changes
|
File without changes
|
File without changes
|
{wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/_credential_manager_asynchronous.py
RENAMED
File without changes
|
{wcp_library-1.5.8 → wcp_library-1.6.2}/wcp_library/credentials/_credential_manager_synchronous.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|