OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
heavydb.connection Namespace Reference

Classes

class  Connection
 

Functions

def connect
 
def _parse_uri
 

Variables

tuple ConnectionInfo
 

Detailed Description

Connect to an HeavyDB database.

Function Documentation

def heavydb.connection._parse_uri (   uri)
private
Parse connection string

Parameters
----------
uri: str
    a URI containing connection information

Returns
-------
info: ConnectionInfo

Notes
------
The URI may include information on

- user
- password
- host
- port
- dbname
- protocol
- bin_cert_validate
- bin_ca_certs

Definition at line 121 of file connection.py.

Referenced by tests.test_connection.TestURI.test_parse_uri().

122 def _parse_uri(uri):
123  """
124  Parse connection string
125 
126  Parameters
127  ----------
128  uri: str
129  a URI containing connection information
130 
131  Returns
132  -------
133  info: ConnectionInfo
134 
135  Notes
136  ------
137  The URI may include information on
138 
139  - user
140  - password
141  - host
142  - port
143  - dbname
144  - protocol
145  - bin_cert_validate
146  - bin_ca_certs
147  """
148  url = make_url(uri)
149  user = url.username
150  password = url.password
151  host = url.host
152  port = url.port
153  dbname = url.database
154  protocol = url.query.get('protocol', 'binary')
155  bin_cert_validate = url.query.get('bin_cert_validate', None)
156  bin_ca_certs = url.query.get('bin_ca_certs', None)
157 
158  return ConnectionInfo(
159  user,
160  password,
161  host,
162  port,
163  dbname,
164  protocol,
165  bin_cert_validate,
166  bin_ca_certs,
167  )
168 

+ Here is the caller graph for this function:

def heavydb.connection.connect (   uri = None,
  user = None,
  password = None,
  host = None,
  port = 6274,
  dbname = None,
  protocol = 'binary',
  sessionid = None,
  bin_cert_validate = None,
  bin_ca_certs = None,
  idpurl = None,
  idpformusernamefield = 'username',
  idpformpasswordfield = 'password',
  idpsslverify = True 
)
Create a new Connection.

Parameters
----------
uri: str
user: str
password: str
host: str
port: int
dbname: str
protocol: {'binary', 'http', 'https'}
sessionid: str
bin_cert_validate: bool, optional, binary encrypted connection only
    Whether to continue if there is any certificate error
bin_ca_certs: str, optional, binary encrypted connection only
    Path to the CA certificate file
idpurl : str
    EXPERIMENTAL Enable SAML authentication by providing
    the logon page of the SAML Identity Provider.
idpformusernamefield: str
    The HTML form ID for the username, defaults to 'username'.
idpformpasswordfield: str
    The HTML form ID for the password, defaults to 'password'.
idpsslverify: str
    Enable / disable certificate checking, defaults to True.

Returns
-------
conn: Connection

Examples
--------
You can either pass a string ``uri``, all the individual components,
or an existing sessionid excluding user, password, and database

>>> connect('heavydb://admin:HyperInteractive@localhost:6274/heavyai?'
...         'protocol=binary')
Connection(mapd://mapd:***@localhost:6274/mapd?protocol=binary)

>>> connect(user='admin', password='HyperInteractive', host='localhost',
...         port=6274, dbname='heavyai')

>>> connect(user='admin', password='HyperInteractive', host='localhost',
...         port=443, idpurl='https://sso.localhost/logon',
            protocol='https')

>>> connect(sessionid='XihlkjhdasfsadSDoasdllMweieisdpo', host='localhost',
...         port=6273, protocol='http')

Definition at line 51 of file connection.py.

Referenced by tests.conftest.con(), tests.test_cursor.mock_connection(), tests.test_connection.TestConnect.test_bad_binary_encryption_params(), tests.test_connection.TestConnect.test_bad_protocol(), tests.test_connection.TestURI.test_both_raises(), tests.test_connection.TestConnect.test_close(), tests.test_integration.TestIntegration.test_connect_binary(), tests.test_integration.TestIntegration.test_connect_http(), tests.test_integration.TestIntegration.test_connect_uri(), tests.test_integration.TestIntegration.test_connect_uri_and_others_raises(), tests.test_connection.TestConnect.test_host_specified(), tests.test_connection.TestConnect.test_raises_right_exception(), tests.test_connection.TestConnect.test_session_logon_failure(), and tests.test_connection.TestConnect.test_session_logon_success().

51 
52 ):
53  """
54  Create a new Connection.
55 
56  Parameters
57  ----------
58  uri: str
59  user: str
60  password: str
61  host: str
62  port: int
63  dbname: str
64  protocol: {'binary', 'http', 'https'}
65  sessionid: str
66  bin_cert_validate: bool, optional, binary encrypted connection only
67  Whether to continue if there is any certificate error
68  bin_ca_certs: str, optional, binary encrypted connection only
69  Path to the CA certificate file
70  idpurl : str
71  EXPERIMENTAL Enable SAML authentication by providing
72  the logon page of the SAML Identity Provider.
73  idpformusernamefield: str
74  The HTML form ID for the username, defaults to 'username'.
75  idpformpasswordfield: str
76  The HTML form ID for the password, defaults to 'password'.
77  idpsslverify: str
78  Enable / disable certificate checking, defaults to True.
79 
80  Returns
81  -------
82  conn: Connection
83 
84  Examples
85  --------
86  You can either pass a string ``uri``, all the individual components,
87  or an existing sessionid excluding user, password, and database
88 
89  >>> connect('heavydb://admin:HyperInteractive@localhost:6274/heavyai?'
90  ... 'protocol=binary')
91  Connection(mapd://mapd:***@localhost:6274/mapd?protocol=binary)
92 
93  >>> connect(user='admin', password='HyperInteractive', host='localhost',
94  ... port=6274, dbname='heavyai')
95 
96  >>> connect(user='admin', password='HyperInteractive', host='localhost',
97  ... port=443, idpurl='https://sso.localhost/logon',
98  protocol='https')
99 
100  >>> connect(sessionid='XihlkjhdasfsadSDoasdllMweieisdpo', host='localhost',
101  ... port=6273, protocol='http')
102 
103  """
104  return Connection(
105  uri=uri,
106  user=user,
107  password=password,
108  host=host,
109  port=port,
110  dbname=dbname,
111  protocol=protocol,
112  sessionid=sessionid,
113  bin_cert_validate=bin_cert_validate,
114  bin_ca_certs=bin_ca_certs,
115  idpurl=idpurl,
116  idpformusernamefield=idpformusernamefield,
117  idpformpasswordfield=idpformpasswordfield,
118  idpsslverify=idpsslverify,
119  )
120 

+ Here is the caller graph for this function:

Variable Documentation

tuple heavydb.connection.ConnectionInfo
Initial value:
1 = namedtuple(
2  "ConnectionInfo",
3  [
4  'user',
5  'password',
6  'host',
7  'port',
8  'dbname',
9  'protocol',
10  'bin_cert_validate',
11  'bin_ca_certs',
12  ],
13 )

Definition at line 21 of file connection.py.

Referenced by DBHandler.getConnectionInfo(), and tests.test_connection.TestURI.test_parse_uri().