MySQL Forums
Forum List  »  Connector/Python

Python mysql-connector not working on Windows machine (Process ended with exit code 3221225477)
Posted by: Lukas Petrikas
Date: June 12, 2025 02:07AM

I have used this library on many Windows machines and I have noticed some strange behaviour. On some Windows machines it works without any issues, while other machines are giving error Process ended with exit code 3221225477.
when trying to run Python script that uses mysql-connector-python.

I have simply picked up a new Desktop PC, installed Python 3.12.7 and intalled mysql-connector-python library. See the logs below:

C:\Users\Testavimas>python -m pip install mysql-connector-python
Collecting mysql-connector-python
Using cached mysql_connector_python-9.3.0-cp312-cp312-win_amd64.whl.metadata (7.7 kB)
Using cached mysql_connector_python-9.3.0-cp312-cp312-win_amd64.whl (16.4 MB)
Installing collected packages: mysql-connector-python
Successfully installed mysql-connector-python-9.3.0

[notice] A new release of pip is available: 24.2 -> 25.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip


Then I try to run the following script:

import mysql.connector
import argparse
import sys
# --- Configuration (replace with your actual credentials) ---
DB_CONFIG = {
'host': 'test.test.lt',
'user': 'lukas',
'password': '(o*5rR[test',
'database': 'Testing',
}
# ------------------------------------------------------------


def get_all_iccids():
"""Fetch all ICCIDs from the database and return them as a list."""
connection = None
cursor = None
try:
connection = mysql.connector.connect(**DB_CONFIG)
cursor = connection.cursor()
cursor.execute("SELECT iccid FROM test_SIM_list")
result = cursor.fetchall()
return [row[0] for row in result]
except mysql.connector.Error as err:
print(f"Database error: {err}")
return []
finally:
if cursor:
cursor.close()
if connection:
connection.close()


def is_valid_iccid(iccid_to_check):
"""Check if the given ICCID exists in the list fetched from DB."""
iccid_list = get_all_iccids()
return 1 if iccid_to_check in iccid_list else 0


def main():
#parser = argparse.ArgumentParser(description="Validate ICCID against database list.")
#parser.add_argument("-iccid", required=True, help="ICCID to validate")
#args = parser.parse_args()

if is_valid_iccid("8937002230500332420"):
print("ICCID is valid.")
return 1
else:
print("ICCID is not valid.")
return 0


if __name__ == "__main__":
result = main()
sys.exit(result)


When I run it using Python IDE (Thonny), it crashes with the error:
Process ended with exit code 3221225477.


When I debug the code, I can see that it crashes at this line:
connection = mysql.connector.connect(**DB_CONFIG)




I have tried to use pymysql just for testing and it worked without any issues.



I would appreciate any kind of advice how to debug this issue, what can I check to figure out what is the root cause of this? Is this related to PC? Is this related to Windows? Is this related to mysql-connector-python?

Options: ReplyQuote


Subject
Written By
Posted
Python mysql-connector not working on Windows machine (Process ended with exit code 3221225477)
June 12, 2025 02:07AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.