#!/usr/bin/env python3 from mysql import connector # Create connection and cursor instance # ===================================== # This part should likely be updated with the tester credentials in order to # reproduce the bug connection = connector.connect( user='foo', password='bar', database='test', ) cursor = connection.cursor() # Define the temporary table and populate it with some values # =========================================================== results = cursor.execute( """ CREATE TEMPORARY TABLE bug_connector_zerofill( id INT(4) UNSIGNED ZEROFILL NOT NULL ); INSERT INTO bug_connector_zerofill (id) VALUES (1), (10), (100), (1000); """, multi=True ) for result in results: if result.with_rows: for row in result: pass # Test of a ZEROFILL without left-padding # ======================================= cursor.execute( """ SELECT id FROM bug_connector_zerofill WHERE id=1000 """ ) # This assertion pass assert cursor.fetchall() == [(1000,)] # Test of a ZEROFILL with padding # =============================== cursor.execute( """ SELECT id FROM bug_connector_zerofill WHERE id=1 """ ) # Up to here, everything works fine print('--------------- Hello word ------------') # The following statement will raise the following error: assert cursor.fetchall() == [(1,)]