OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
omnisci.connection Namespace Reference

Classes

class  Connection
 

Functions

def connect
 
def _parse_uri
 

Variables

tuple ConnectionInfo
 

Detailed Description

Connect to an OmniSci database.

Function Documentation

def omnisci.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 124 of file connection.py.

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

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

+ Here is the caller graph for this function:

def omnisci.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('mapd://admin:HyperInteractive@localhost:6274/omnisci?'
...         'protocol=binary')
Connection(mapd://mapd:***@localhost:6274/mapd?protocol=binary)

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

>>> 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 54 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().

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

+ Here is the caller graph for this function:

Variable Documentation

tuple omnisci.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 24 of file connection.py.

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