hana-cloud-interface 0.1.7__py3-none-any.whl → 0.1.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.

Potentially problematic release.


This version of hana-cloud-interface might be problematic. Click here for more details.

@@ -1 +1 @@
1
- from .main import hana_sql, initialize_settings
1
+ from .main import hana_sql, initialize_settings, hana_upload
@@ -12,6 +12,7 @@ from hdbcli import dbapi
12
12
  import polars as pl
13
13
  import pandas as pd
14
14
  import os
15
+ from hana_ml.dataframe import ConnectionContext, create_dataframe_from_pandas
15
16
 
16
17
  config_file_g = ''
17
18
  Browser_override_g = ''
@@ -247,4 +248,34 @@ def hana_sql(sql_command='test',DF_type = data_frame_type_g):
247
248
  return pl.DataFrame(data,orient='row',schema=data_name)
248
249
  else:
249
250
  raise ValueError("DF_type must be either 'pandas' or 'polars'")
250
-
251
+
252
+ def hana_upload(data, data_name, SCHEMA):
253
+ """
254
+ Uploads a pandas DataFrame to an SAP HANA Cloud table.
255
+ Args:
256
+ data (pandas.DataFrame): The DataFrame to upload to HANA.
257
+ data_name (str): The name of the target table in HANA.
258
+ SCHEMA (str): The schema in which the table resides.
259
+ Returns:
260
+ bool: True if the upload is successful.
261
+ Notes:
262
+ - Uses JWT authentication to connect to SAP HANA Cloud.
263
+ - Overwrites the target table if it exists (force=True, replace=True).
264
+ - Requires valid OAuth token stored in the system keyring under 'SAP_hana_sso'.
265
+ """
266
+
267
+
268
+ cursor = get_token()
269
+ cursor.close()
270
+
271
+ #oauth_config = config_reader()
272
+ oauth_Token = keyring.get_password('SAP_hana_sso', 'oauth_Token')
273
+ oauth_Token = json.loads(oauth_Token)
274
+
275
+ conn = ConnectionContext(address=oauth_Token['prod_URL'],port='443',authenticationMethods='jwt',password=oauth_Token['access_token'],encrypt=True, sslValidateCertificate=True)
276
+
277
+ create_dataframe_from_pandas(conn, data, data_name,
278
+ schema=SCHEMA,
279
+ force=True, # True: truncate and insert
280
+ replace=True) # True: Null is replaced by 0
281
+ return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hana-cloud-interface
3
- Version: 0.1.7
3
+ Version: 0.1.8
4
4
  Summary: Runs a SQL command on SAP HANA Cloud using OAuth single sign on and returns a pandas or polars dataframe
5
5
  Author: charlotte corpe
6
6
  Author-email: charlotte corpe <charlotte.corpe@powerco.co.nz>
@@ -8,6 +8,7 @@ Requires-Dist: keyring
8
8
  Requires-Dist: hdbcli
9
9
  Requires-Dist: polars
10
10
  Requires-Dist: pandas
11
+ Requires-Dist: hana-ml
11
12
  Requires-Python: >=3.12
12
13
  Description-Content-Type: text/markdown
13
14
 
@@ -0,0 +1,6 @@
1
+ hana_cloud_interface/__init__.py,sha256=e5ad9ac976f45e69e10ed15428aebff1c38da50de323dd6ab8a47d57180eff1c,60
2
+ hana_cloud_interface/main.py,sha256=94d29e9fe510f00abf7e7ed3807cb9b96425e9125d89d8343100a6090df5fee7,10991
3
+ hana_cloud_interface/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
4
+ hana_cloud_interface-0.1.8.dist-info/WHEEL,sha256=b70116f4076fa664af162441d2ba3754dbb4ec63e09d563bdc1e9ab023cce400,78
5
+ hana_cloud_interface-0.1.8.dist-info/METADATA,sha256=a58abfe65769e698df49875991446f49c513e9b3a5c7d6fcc070d611b442837e,1966
6
+ hana_cloud_interface-0.1.8.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- hana_cloud_interface/__init__.py,sha256=906f9595b4c5204bd8fa8ee1339d5a60da87904eb00bafaec724ab8c9f0e7305,47
2
- hana_cloud_interface/main.py,sha256=72c5ca2bc15ef8da55d8a8dcd3500cd2a8dbb8e744bb3999962e141dcd002580,9650
3
- hana_cloud_interface/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
4
- hana_cloud_interface-0.1.7.dist-info/WHEEL,sha256=b70116f4076fa664af162441d2ba3754dbb4ec63e09d563bdc1e9ab023cce400,78
5
- hana_cloud_interface-0.1.7.dist-info/METADATA,sha256=4ddd10b178a90250786537b3be366069dfb0d392fff63b2102024aec853b6f4b,1943
6
- hana_cloud_interface-0.1.7.dist-info/RECORD,,