hana-cloud-interface 0.1.7__tar.gz → 0.1.8__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.
Potentially problematic release.
This version of hana-cloud-interface might be problematic. Click here for more details.
- {hana_cloud_interface-0.1.7 → hana_cloud_interface-0.1.8}/PKG-INFO +2 -1
- {hana_cloud_interface-0.1.7 → hana_cloud_interface-0.1.8}/pyproject.toml +2 -2
- hana_cloud_interface-0.1.8/src/hana_cloud_interface/__init__.py +1 -0
- {hana_cloud_interface-0.1.7 → hana_cloud_interface-0.1.8}/src/hana_cloud_interface/main.py +32 -1
- hana_cloud_interface-0.1.7/src/hana_cloud_interface/__init__.py +0 -1
- {hana_cloud_interface-0.1.7 → hana_cloud_interface-0.1.8}/README.md +0 -0
- {hana_cloud_interface-0.1.7 → hana_cloud_interface-0.1.8}/src/hana_cloud_interface/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: hana-cloud-interface
|
|
3
|
-
Version: 0.1.
|
|
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
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "hana-cloud-interface"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.8"
|
|
4
4
|
description = "Runs a SQL command on SAP HANA Cloud using OAuth single sign on and returns a pandas or polars dataframe"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
7
7
|
{ name = "charlotte corpe", email = "charlotte.corpe@powerco.co.nz" }
|
|
8
8
|
]
|
|
9
9
|
requires-python = ">=3.12"
|
|
10
|
-
dependencies = ['keyring','hdbcli','polars','pandas']
|
|
10
|
+
dependencies = ['keyring','hdbcli','polars','pandas','hana_ml']
|
|
11
11
|
|
|
12
12
|
[build-system]
|
|
13
13
|
requires = ["uv_build>=0.8.3,<0.9.0"]
|
|
@@ -0,0 +1 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
from .main import hana_sql, initialize_settings
|
|
File without changes
|
|
File without changes
|