hana-cloud-interface 0.1.5__py3-none-any.whl → 0.1.7__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 = ''
17
- Browser_override = ''
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_override_g != '':
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hana-cloud-interface
3
- Version: 0.1.5
3
+ Version: 0.1.7
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>
@@ -32,11 +32,17 @@ data = hci.hana_sql(sql_command)
32
32
 
33
33
  ```
34
34
 
35
- ## Configuration file
36
- You need specify the location of your configuration file by setting the `config_file` attribute of the `hci` module. For example:
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'.
37
43
 
38
44
  ```python
39
- hci.config_file = 'location of configuration file'
45
+ hci.initialize_settings(config_file = 'location of configuration file', Browser_override = '', data_frame_type = 'pandas')
40
46
  ```
41
47
  the configuration file is a .json file
42
48
  ```python
@@ -0,0 +1,6 @@
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,,
@@ -1,6 +0,0 @@
1
- hana_cloud_interface/__init__.py,sha256=afee63541644ae210da90e08e3cee1af035edaa6905ff49ee2ac2aca921e6897,74
2
- hana_cloud_interface/main.py,sha256=7efa064a184742ddf9255ec8de4ff326deec495aa4af7fd297d662cfc8091cf1,8923
3
- hana_cloud_interface/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
4
- hana_cloud_interface-0.1.5.dist-info/WHEEL,sha256=b70116f4076fa664af162441d2ba3754dbb4ec63e09d563bdc1e9ab023cce400,78
5
- hana_cloud_interface-0.1.5.dist-info/METADATA,sha256=1b2342c771e8c91f30a03ecff86a9a3fe29450bd7363089803ea9b5764ac6900,1373
6
- hana_cloud_interface-0.1.5.dist-info/RECORD,,