hana-cloud-interface 0.1.4__py3-none-any.whl → 0.1.6__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, config_file, data_frame_type, Browser_override
1
+ from .main import hana_sql, initialize_settings
@@ -13,11 +13,29 @@ import polars as pl
13
13
  import pandas as pd
14
14
  import os
15
15
 
16
- config_file = r'C:\python\Hana_Cloud_interface\hc_oauth_config.json'
17
- Browser_override = r'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
18
- data_frame_type = 'pandas' # Default data frame type for hana_sql function
16
+ config_file_g = ''
17
+ Browser_override_g = ''
18
+ data_frame_type_g = 'pandas' # Default data frame type for hana_sql function
19
19
  debug = False
20
20
 
21
+ def initialize_settings(config_file = '', Browser_override = '', data_frame_type = 'pandas'):
22
+ """
23
+ Initializes global settings for the Hana Cloud interface.
24
+
25
+ Parameters:
26
+ config_file (str): Path to the configuration file.
27
+ Browser_override (str): Optional browser override for OAuth authentication.
28
+ data_frame_type (str): Default data frame type for SQL query results ('pandas' or 'polars').
29
+
30
+ Sets global variables for configuration file path, browser override, and data frame type.
31
+ """
32
+ global config_file_g, Browser_override_g, data_frame_type_g
33
+ config_file_g = config_file
34
+ Browser_override_g = Browser_override
35
+ data_frame_type_g = data_frame_type
36
+
37
+
38
+
21
39
  def test_connection(oauth_config):
22
40
  oauth_Token = keyring.get_password('SAP_hana_sso', 'oauth_Token')
23
41
 
@@ -159,8 +177,8 @@ def get_token(i=0):
159
177
  authorization_url = f"{oauth_config['AUTH_URL']}?{urllib.parse.urlencode(params)}"
160
178
 
161
179
  # Open web browser and go to oauth url
162
- if Browser_override != '':
163
- webbrowser.get(Browser_override).open(authorization_url,new=1)
180
+ if Browser_overrid_ge != '':
181
+ webbrowser.get(Browser_override_g).open(authorization_url,new=1)
164
182
  else:
165
183
  webbrowser.open(authorization_url,new=1)
166
184
 
@@ -188,9 +206,9 @@ def config_reader():
188
206
  # reads config data from keychain
189
207
  config_data = keyring.get_password('SAP_hana_sso', 'config_data')
190
208
  if not config_data: # If there is no existing config data saved to the credentials manager read from file and save it
191
- if not os.path.exists(config_file):
192
- raise FileNotFoundError(f"Config file not found: {config_file}")
193
- with open(config_file) as file:
209
+ if not os.path.exists(config_file_g):
210
+ raise FileNotFoundError(f"Config file not found: {config_file_g}")
211
+ with open(config_file_g) as file:
194
212
  config_data = json.load(file)
195
213
  keyring.set_password('SAP_hana_sso', 'config_data', json.dumps(config_data))
196
214
  return config_data
@@ -200,7 +218,7 @@ def config_reader():
200
218
 
201
219
 
202
220
 
203
- def hana_sql(sql_command='test',DF_type = data_frame_type):
221
+ def hana_sql(sql_command='test',DF_type = data_frame_type_g):
204
222
  """ handles single sign on then runs a SQL command
205
223
 
206
224
  Parameters:
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.3
2
+ Name: hana-cloud-interface
3
+ Version: 0.1.6
4
+ Summary: Runs a SQL command on SAP HANA Cloud using OAuth single sign on and returns a pandas or polars dataframe
5
+ Author: charlotte corpe
6
+ Author-email: charlotte corpe <charlotte.corpe@powerco.co.nz>
7
+ Requires-Dist: keyring
8
+ Requires-Dist: hdbcli
9
+ Requires-Dist: polars
10
+ Requires-Dist: pandas
11
+ Requires-Python: >=3.12
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Usage of the `hana_cloud_interface` package
15
+
16
+ This package provides a simple interface to connect to SAP HANA Cloud databases and execute SQL queries. Below are some examples of how to use the package.
17
+
18
+
19
+ ## example
20
+ the main function is very simple It takes a SQL command as a string and returns the data
21
+ ```python
22
+ import hana_cloud_interface as hci
23
+
24
+ sql_command = """
25
+ SELECT top 10
26
+ "data1"
27
+ "data2"
28
+ FROM "table1"
29
+ """
30
+
31
+ data = hci.hana_sql(sql_command)
32
+
33
+ ```
34
+
35
+ ## initialising settings
36
+ Before using the package, you need to initialize the settings by specifying the configuration file location, browser override (if needed), and the default data frame type for SQL query results.
37
+
38
+ config_file : Path to the configuration file (JSON format) containing OAuth credentials and other settings.
39
+
40
+ Browser_override : Optional parameter to specify a browser for OAuth authentication. If left empty, the default browser will be used. this needs to be the path to the executable for the browser
41
+
42
+ data_frame_type : Default data frame type for SQL query results. Options are 'pandas' or 'polars'. Default is 'pandas'.
43
+
44
+ ```python
45
+ hci.initialize_settings(config_file = 'location of configuration file', Browser_override = '', data_frame_type = 'pandas')
46
+ ```
47
+ the configuration file is a .json file
48
+ ```python
49
+ {
50
+ "CLIENT_ID": "",
51
+ "CLIENT_SECRET": "",
52
+ "AUTH_URL": "",
53
+ "TOKEN_URL": "",
54
+ "protected_url": "",
55
+ "REDIRECT_URI": "",
56
+ "SCOPE": "",
57
+ "HC_prod_URL": ""
58
+ }
59
+ ```
@@ -0,0 +1,6 @@
1
+ hana_cloud_interface/__init__.py,sha256=906f9595b4c5204bd8fa8ee1339d5a60da87904eb00bafaec724ab8c9f0e7305,47
2
+ hana_cloud_interface/main.py,sha256=9ce84770db8c48a87095ac803c2d4a6844c29dbf3917c9b10f2f1bcaacf46857,9650
3
+ hana_cloud_interface/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
4
+ hana_cloud_interface-0.1.6.dist-info/WHEEL,sha256=b70116f4076fa664af162441d2ba3754dbb4ec63e09d563bdc1e9ab023cce400,78
5
+ hana_cloud_interface-0.1.6.dist-info/METADATA,sha256=0937d4566f52bd35053a0eb598cb7d9304510ad1932f8bb6c4462ba59c58a270,1943
6
+ hana_cloud_interface-0.1.6.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: hana-cloud-interface
3
- Version: 0.1.4
4
- Summary: Runs a SQL command on SAP HANA Cloud using OAuth single sign on and returns a pandas or polars dataframe
5
- Author: charlotte corpe
6
- Author-email: charlotte corpe <charlotte.corpe@powerco.co.nz>
7
- Requires-Dist: keyring
8
- Requires-Dist: hdbcli
9
- Requires-Dist: polars
10
- Requires-Dist: pandas
11
- Requires-Python: >=3.12
12
- Description-Content-Type: text/markdown
13
-
@@ -1,6 +0,0 @@
1
- hana_cloud_interface/__init__.py,sha256=afee63541644ae210da90e08e3cee1af035edaa6905ff49ee2ac2aca921e6897,74
2
- hana_cloud_interface/main.py,sha256=123fc760b710e70e85564de442f06a7810ab311a85f6995864d083976e06538a,9036
3
- hana_cloud_interface/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
4
- hana_cloud_interface-0.1.4.dist-info/WHEEL,sha256=b70116f4076fa664af162441d2ba3754dbb4ec63e09d563bdc1e9ab023cce400,78
5
- hana_cloud_interface-0.1.4.dist-info/METADATA,sha256=1f4beef9c115ff3f16be964202a5ddab8fd558c4f5bd081000870049fdab5822,418
6
- hana_cloud_interface-0.1.4.dist-info/RECORD,,