Skip to content

Commit baf81ea

Browse files
author
Reggie Burnett
committed
Merge branch 'release/2.2.0' of myrepo.no.oracle.com:connector-python into release/2.2.0
2 parents 4a2cb2f + bc01d73 commit baf81ea

File tree

11 files changed

+813
-806
lines changed

11 files changed

+813
-806
lines changed

cpyint

lib/mysqlx/connection.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525

2626
import socket
2727

28-
from .protocol import Protocol, MessageReaderWriter
2928
from .authentication import MySQL41AuthPlugin
30-
from .result import Result, RowResult, DocResult
29+
from .errors import InterfaceError
3130
from .crud import Schema
31+
from .protocol import Protocol, MessageReaderWriter
32+
from .result import Result, RowResult, DocResult
3233
from .statement import SqlStatement
3334

3435
_DROP_DATABASE_QUERY = "DROP DATABASE IF EXISTS `{0}`"
@@ -117,7 +118,7 @@ def execute_sql_scalar(self, sql, *args):
117118
result = RowResult(self)
118119
result.fetch_all()
119120
if result.count == 0:
120-
raise Exception("No data found")
121+
raise InterfaceError("No data found")
121122
return result[0][0]
122123

123124
def get_row_result(self, cmd, *args):

lib/mysqlx/crud.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
"""Implementation of the CRUD database objects."""
2525

26+
from .errors import ProgrammingError
2627
from .statement import (FindStatement, AddStatement, RemoveStatement,
2728
ModifyStatement, SelectStatement, InsertStatement,
2829
DeleteStatement, UpdateStatement,
@@ -158,7 +159,7 @@ def get_table(self, name, check_existence=False):
158159
table = Table(self, name)
159160
if check_existence:
160161
if not table.exists_in_database():
161-
raise Exception("table does not exist")
162+
raise ProgrammingError("Table does not exist")
162163
return table
163164

164165
def get_collection(self, name, check_existence=False):
@@ -170,7 +171,7 @@ def get_collection(self, name, check_existence=False):
170171
collection = Collection(self, name)
171172
if check_existence:
172173
if not collection.exists_in_database():
173-
raise Exception("collection does not exist")
174+
raise ProgrammingError("Collection does not exist")
174175
return collection
175176

176177
def drop_collection(self, name):
@@ -207,7 +208,7 @@ def create_collection(self, name, reuse=False):
207208
self._connection.execute_nonquery("xplugin", "create_collection",
208209
True, self._name, name)
209210
elif not reuse:
210-
raise Exception("Collection already exists")
211+
raise ProgrammingError("Collection already exists")
211212
return collection
212213

213214

lib/mysqlx/dbdoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, value):
4343
elif isinstance(value, basestring):
4444
self.__dict__ = json.loads(value)
4545
else:
46-
raise Exception("Unable to handle type: ".format(type(value)))
46+
raise ValueError("Unable to handle type: ".format(type(value)))
4747

4848
def __getitem__(self, index):
4949
return self.__dict__[index]

0 commit comments

Comments
 (0)