wcp-library 1.1.9__py3-none-any.whl → 1.2.2__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/__init__.py CHANGED
@@ -13,3 +13,16 @@ if getattr(sys, 'frozen', False):
13
13
  application_path = Path(application_path).parent
14
14
  else:
15
15
  application_path = Path().absolute()
16
+
17
+
18
+ def divide_chunks(list_obj: list, size: int) -> list:
19
+ """
20
+ Divide a list into chunks of size
21
+
22
+ :param list_obj:
23
+ :param size:
24
+ :return:
25
+ """
26
+
27
+ for i in range(0, len(list_obj), size):
28
+ yield list_obj[i:i + size]
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  from typing import Optional
3
3
 
4
+ import numpy as np
4
5
  import pandas as pd
5
6
  import oracledb
6
7
  from oracledb import AsyncConnectionPool
@@ -204,14 +205,17 @@ class AsyncOracleConnection(object):
204
205
  bindList.append(':' + column)
205
206
  bind = ', '.join(bindList)
206
207
 
207
- main_dict = dfObj.to_dict('records')
208
208
  if remove_nan:
209
- for val, item in enumerate(main_dict):
210
- for sub_item, value in item.items():
211
- if pd.isna(value):
212
- main_dict[val][sub_item] = None
213
- else:
214
- main_dict[val][sub_item] = value
209
+ dfObj = dfObj.replace({np.nan: None})
210
+ main_dict = dfObj.to_dict('records')
211
+
212
+ # if remove_nan:
213
+ # for val, item in enumerate(main_dict):
214
+ # for sub_item, value in item.items():
215
+ # if pd.isna(value):
216
+ # main_dict[val][sub_item] = None
217
+ # else:
218
+ # main_dict[val][sub_item] = value
215
219
 
216
220
  query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, bind)
217
221
  await self.execute_many(query, main_dict)
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  from typing import Optional
3
3
 
4
+ import numpy as np
4
5
  import pandas as pd
5
6
  from psycopg.sql import SQL
6
7
  from psycopg_pool import AsyncConnectionPool
@@ -187,14 +188,17 @@ class AsyncPostgresConnection(object):
187
188
  param_list.append(f"%({column})s")
188
189
  params = ', '.join(param_list)
189
190
 
190
- main_dict = dfObj.to_dict('records')
191
191
  if remove_nan:
192
- for val, item in enumerate(main_dict):
193
- for sub_item, value in item.items():
194
- if pd.isna(value):
195
- main_dict[val][sub_item] = None
196
- else:
197
- main_dict[val][sub_item] = value
192
+ dfObj = dfObj.replace({np.nan: None})
193
+ main_dict = dfObj.to_dict('records')
194
+
195
+ # if remove_nan:
196
+ # for val, item in enumerate(main_dict):
197
+ # for sub_item, value in item.items():
198
+ # if pd.isna(value):
199
+ # main_dict[val][sub_item] = None
200
+ # else:
201
+ # main_dict[val][sub_item] = value
198
202
 
199
203
  query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, params)
200
204
  await self.execute_many(query, main_dict)
wcp_library/sql/oracle.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  from typing import Optional
3
3
 
4
+ import numpy as np
4
5
  import pandas as pd
5
6
  import oracledb
6
7
  from oracledb import ConnectionPool
@@ -208,14 +209,17 @@ class OracleConnection(object):
208
209
  bindList.append(':' + column)
209
210
  bind = ', '.join(bindList)
210
211
 
211
- main_dict = dfObj.to_dict('records')
212
212
  if remove_nan:
213
- for val, item in enumerate(main_dict):
214
- for sub_item, value in item.items():
215
- if pd.isna(value):
216
- main_dict[val][sub_item] = None
217
- else:
218
- main_dict[val][sub_item] = value
213
+ dfObj = dfObj.replace({np.nan: None})
214
+ main_dict = dfObj.to_dict('records')
215
+
216
+ # if remove_nan:
217
+ # for val, item in enumerate(main_dict):
218
+ # for sub_item, value in item.items():
219
+ # if pd.isna(value):
220
+ # main_dict[val][sub_item] = None
221
+ # else:
222
+ # main_dict[val][sub_item] = value
219
223
 
220
224
  query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, bind)
221
225
  self.execute_many(query, main_dict)
@@ -1,6 +1,7 @@
1
1
  import logging
2
2
  from typing import Optional
3
3
 
4
+ import numpy as np
4
5
  import pandas as pd
5
6
  from psycopg.sql import SQL
6
7
  from psycopg_pool import ConnectionPool
@@ -187,14 +188,17 @@ class PostgresConnection(object):
187
188
  param_list.append(f"%({column})s")
188
189
  params = ', '.join(param_list)
189
190
 
190
- main_dict = dfObj.to_dict('records')
191
191
  if remove_nan:
192
- for val, item in enumerate(main_dict):
193
- for sub_item, value in item.items():
194
- if pd.isna(value):
195
- main_dict[val][sub_item] = None
196
- else:
197
- main_dict[val][sub_item] = value
192
+ dfObj = dfObj.replace({np.nan: None})
193
+ main_dict = dfObj.to_dict('records')
194
+
195
+ # if remove_nan:
196
+ # for val, item in enumerate(main_dict):
197
+ # for sub_item, value in item.items():
198
+ # if pd.isna(value):
199
+ # main_dict[val][sub_item] = None
200
+ # else:
201
+ # main_dict[val][sub_item] = value
198
202
 
199
203
  query = """INSERT INTO {} ({}) VALUES ({})""".format(outputTableName, col, params)
200
204
  self.execute_many(query, main_dict)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.1.9
3
+ Version: 1.2.2
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
@@ -1,11 +1,11 @@
1
- wcp_library/__init__.py,sha256=7JG050lnLc-Djo5MyftR_keI7-vZjlBwmx-LLdEVUCM,349
1
+ wcp_library/__init__.py,sha256=hwLbcu00uI6L_xjXO9-I0YcODl2WtIOkdNLoDcXv7zk,591
2
2
  wcp_library/async_credentials/__init__.py,sha256=ny6UitVV_xIecVzaWuHrJO9LpywBPke6u4C0F2wiM7o,1881
3
3
  wcp_library/async_credentials/api.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
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=T4wLdX3sHQQOfDNqb35GM4wHFP5Vs5veB7iQtdCxPVM,7402
8
- wcp_library/async_sql/postgres.py,sha256=MGPv1ffUDn7oJX1ojviVD3N7jk8dtQERnbDateuwZJo,6597
7
+ wcp_library/async_sql/oracle.py,sha256=W4_zXc3XxNnMZYXmyCCqx4dx1SQ6J8Tf_ifht_d8btI,7509
8
+ wcp_library/async_sql/postgres.py,sha256=gFkgSpJQ7Giwjtjbh-38szhtFHPAt8WbvtZEp7UZ3oM,6704
9
9
  wcp_library/credentials/__init__.py,sha256=HRmg7mqcATeclIz3lZQjSR4nmK6aY6MK9-QXEYZoFrw,1857
10
10
  wcp_library/credentials/ftp.py,sha256=FRxKVWifz7olQIrSjDgkTqk7rmc7Zdwmkfq7b62DQY8,4965
11
11
  wcp_library/credentials/oracle.py,sha256=IJVGd10LH5LUNKUSFAbApi0sjR1AbloMJRHTuR9zFrQ,5095
@@ -18,8 +18,8 @@ wcp_library/informatica.py,sha256=IXZtk_9X1XLbOEwFrsyOwTgajQKvtXgANBHmuTOP3Kk,40
18
18
  wcp_library/logging.py,sha256=tpnEuet-V6SK68JWk5cpt4K51YO0AxaebXrwGDGabFs,2048
19
19
  wcp_library/selenium_helper.py,sha256=rlphTXsUgnbaXZknY5nfQqxFhnc7UmrpzhV3hQ-cv7k,2509
20
20
  wcp_library/sql/__init__.py,sha256=CLlBEBrWVAwE79bUxuQiwikSrYH8m9QRYSJ2l0-ofsY,1003
21
- wcp_library/sql/oracle.py,sha256=QT1-SHMs6ebQpzkJ1vjgsAP5TWHDdJF7pWL9QJ52O9Y,7235
22
- wcp_library/sql/postgres.py,sha256=I2iDQ13z_hbEfpFBliozLfsg8xUdSzEVqr12yyPSdh4,6489
23
- wcp_library-1.1.9.dist-info/METADATA,sha256=pT9xT59f-L2Adxx5ExaP9m8-r0J_vpHTPmpz82zbt5o,1513
24
- wcp_library-1.1.9.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
25
- wcp_library-1.1.9.dist-info/RECORD,,
21
+ wcp_library/sql/oracle.py,sha256=a0wc9zwBdzhZCZFRWxZlokDJEEt-HqhqmwRbtp2T8ZA,7342
22
+ wcp_library/sql/postgres.py,sha256=397Ii0ImjEo_e_QuWJRazfs0WpT9cGrnc6sBPyr4UyY,6596
23
+ wcp_library-1.2.2.dist-info/METADATA,sha256=c3w7APbcjSEvXv1JFvRJzyyxMSgi7RuaZ_pYfs2nS_s,1513
24
+ wcp_library-1.2.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
25
+ wcp_library-1.2.2.dist-info/RECORD,,