Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_nonexistant_table_raises(self, nonexistant_table):
result = _translate_exception(nonexistant_table)
assert isinstance(result, DatabaseError)
assert "Exception occurred: Table" in result.args[0]
def test_invalid_sql_raises(self, invalid_sql):
result = _translate_exception(invalid_sql)
assert isinstance(result, ProgrammingError)
assert 'Validate failed: From line 1,' in result.args[0]
if e.NOT_OPEN:
err = OperationalError("Could not connect to database")
raise err from e
else:
raise
self._client = Client(proto)
try:
# If a sessionid was passed, we should validate it
if sessionid:
self._session = sessionid
self.get_tables()
self.sessionid = sessionid
else:
self._session = self._client.connect(user, password, dbname)
except TMapDException as e:
raise _translate_exception(e) from e
except TTransportException:
raise ValueError(f"Connection failed with port {port} and "
f"protocol '{protocol}'. Try port 6274 for "
"protocol == binary or 6273, 6278 or 443 for "
"http[s]"
)
# if OmniSci version <4.6, raise RuntimeError, as data import can be
# incorrect for columnar date loads
# Caused by https://github.com/omnisci/pymapd/pull/188
semver = self._client.get_version()
if Version(semver.split("-")[0]) < Version("4.6"):
raise RuntimeError(f"Version {semver} of OmniSci detected. "
"Please use pymapd <0.11. See release notes "
[('RHAT', 100.0), ('IBM', 500.0)]
"""
# https://github.com/omnisci/pymapd/issues/263
operation = operation.strip()
if parameters is not None:
operation = str(_bind_parameters(operation, parameters))
self.rowcount = -1
try:
result = self.connection._client.sql_execute(
self.connection._session, operation,
column_format=True,
nonce=None, first_n=-1, at_most_n=-1)
except T.TMapDException as e:
raise _translate_exception(e) from e
self._description = _extract_description(result.row_set.row_desc)
try:
self.rowcount = len(result.row_set.columns[0].nulls)
except IndexError:
pass
self._result_set = make_row_results_set(result)
self._result = result
return self