mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-04 08:04:45 +00:00
CONPY-205: Added error constants
Error code constants are now defined in constants/ERR. The file ERR.py is generated by helper/create_errconst.py script, please don't edit it.
This commit is contained in:
24
helper/create_errconst.py
Normal file
24
helper/create_errconst.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
ignore_definitions= ["ERR_ERROR_FIRST", "ER_ERROR_LAST", "CR_MIN_ERROR", "CR_MAX_ERROR",
|
||||||
|
"CER_MIN_ERROR", "CER_MAX_ERROR", "CR_MYSQL_LAST_ERROR", "CR_MARIADB_LAST_ERROR"]
|
||||||
|
|
||||||
|
files= ["https://raw.githubusercontent.com/mariadb-corporation/mariadb-connector-c/3.3/include/mysqld_error.h",
|
||||||
|
"https://raw.githubusercontent.com/mariadb-corporation/mariadb-connector-c/3.3/include/errmsg.h"]
|
||||||
|
|
||||||
|
error_definitions= []
|
||||||
|
|
||||||
|
for i in range(0, len(files)):
|
||||||
|
errors= requests.get(files[i], allow_redirects=True)
|
||||||
|
error_definitions+= errors.content.decode("utf8").split("\n")
|
||||||
|
|
||||||
|
print("# Autogenerated file. Please do not edit!\n\n")
|
||||||
|
|
||||||
|
for i in range(0, len(error_definitions)):
|
||||||
|
x= error_definitions[i].split(" ")
|
||||||
|
if len(x) == 3 and x[0] == "#define" and x[1] not in ignore_definitions and x[1][:9] != "ER_UNUSED":
|
||||||
|
try:
|
||||||
|
if int(x[2]) > 0:
|
||||||
|
print("%s = %s" % (x[1], x[2]))
|
||||||
|
except:
|
||||||
|
pass
|
1227
mariadb/constants/ERR.py
Normal file
1227
mariadb/constants/ERR.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
|||||||
__all__ = ["CLIENT", "CURSOR", "FIELD_TYPE", "FIELD_FLAG", "INDICATOR", 'STATUS']
|
__all__ = ["CLIENT", "CURSOR", "FIELD_TYPE", "FIELD_FLAG", "INDICATOR", 'STATUS', 'ERR']
|
||||||
|
2
setup.py
2
setup.py
@ -98,6 +98,6 @@ setup(name='mariadb',
|
|||||||
py_modules=['mariadb.__init__', 'mariadb.constants.CLIENT', 'mariadb.constants.CURSOR',
|
py_modules=['mariadb.__init__', 'mariadb.constants.CLIENT', 'mariadb.constants.CURSOR',
|
||||||
'mariadb.constants.STATUS', 'mariadb.constants.TPC_STATE', 'mariadb.constants.INFO',
|
'mariadb.constants.STATUS', 'mariadb.constants.TPC_STATE', 'mariadb.constants.INFO',
|
||||||
'mariadb.field', 'mariadb.connections', 'mariadb.connectionpool', 'mariadb.dbapi20',
|
'mariadb.field', 'mariadb.connections', 'mariadb.connectionpool', 'mariadb.dbapi20',
|
||||||
'mariadb.cursors', 'mariadb.release_info',
|
'mariadb.cursors', 'mariadb.release_info', 'mariadb.constants.ERR',
|
||||||
'mariadb.constants.FIELD_TYPE', 'mariadb.constants.FIELD_FLAG', 'mariadb.constants.INDICATOR'],
|
'mariadb.constants.FIELD_TYPE', 'mariadb.constants.FIELD_FLAG', 'mariadb.constants.INDICATOR'],
|
||||||
)
|
)
|
||||||
|
@ -1278,6 +1278,15 @@ class TestCursor(unittest.TestCase):
|
|||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
def test_conpy203(self):
|
||||||
|
conn= create_connection()
|
||||||
|
cursor= conn.cursor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
cursor.execute("SELECT")
|
||||||
|
except mariadb.ProgrammingError as err:
|
||||||
|
self.assertEqual(err.errno, ERR.ER_PARSE_ERROR)
|
||||||
|
|
||||||
def test_conpy91(self):
|
def test_conpy91(self):
|
||||||
with create_connection() as connection:
|
with create_connection() as connection:
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
|
Reference in New Issue
Block a user