Bug #91315 examples bugs
Submitted: 19 Jun 2018 11:49 Modified: 10 Aug 2022 19:17
Reporter: david pay Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.11 OS:Any
Assigned to: CPU Architecture:Any

[19 Jun 2018 11:49] david pay
Description:
In https://dev.mysql.com/doc/connector-python/en/connector-python-example-ddl.html,
there is 
"
try:
    cnx.database = DB_NAME  
except mysql.connector.Error as err:
    ...
" 
to handle exception.
But if you don't set use_pure=True, you can't catch the exception .
As i see, it's c extension, and used 
"from _mysql_connector import MySQLInterfaceError"
they are different Errors,  so the example won't work correctly.
 

How to repeat:
just copy the code, then it won't work.

Suggested fix:
combine them together or add comment not to confusing reader.
[5 Jul 2018 7:19] Chiranjeevi Battula
Hello david,

Thank you for the bug report.
Verified this behavior on Python 3.6 & MySQL Connector/Python 8.0.11.

Thanks,
Chiranjeevi.
[5 Jul 2018 18:32] Philip Olson
Posted by developer:
 
use_pure=true|false should have the same behavior, so changing this to a development bug
[10 Aug 2022 19:17] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Python 8.0.31 release, and here's the proposed changelog entry from the documentation team:

Aligned the exception types raised by pure Python and the C extension
when assigning a non-existent database or when executing an invalid query
using the connection.info_query() method.

Thank you for the bug report.