OiO.lk Blog python mysql-connector-python self._cmysql.connect(**cnx_kwargs) crashes the application
python

mysql-connector-python self._cmysql.connect(**cnx_kwargs) crashes the application


I have issues with my PySide6 application. In the application I am using mysql-connector-python libary and trying to connect to our private Mysql server. I have noticed that on some computers, my application will run without any issues, while on other PC’s it will crash with Process ended with exit code 3221225477.

I have run my application in debug mode where the application is crashing and narrowed down the issue. The issue lies very deep within mysql-connector-python.

  1. In my mainwindow.py, I call:
        self.mysql_db = mysql_db(self)
        print("Mysql class object created")
        if self.mysql_db is not None:
            if (self.mysql_db.DB_start("OUR_DB") == 1):
                self.ui.MYSQL_status_edit.setText("Connected")
                self.ui.database_edit.setText("RND_Testing")
                self.ui.MYSQL_status_edit.setStyleSheet("color: rgb(60, 179, 113);")
            else:
                self.ui.MYSQL_status_edit.setText("Disabled")
                self.ui.MYSQL_status_edit.setStyleSheet("color: rgb(255, 99, 71);")
  1. In my mysql_db.DB_start, I call:
self.mydb mysql.connector.connect(host="server.hostname.lt",user="root",password="password",database=database,connection_timeout
   = timeout)```
  1. mysql connect method returns CMySQLConnection(*args, **kwargs) in pooling.py
  2. In CMySQLConnection class init method (connection_cext.py), it tried to do:
      if kwargs:
            try:
                self.connect(**kwargs)
            except Exception:
                self.close()
                raise
  1. Inside self.connect(**kwargs) from CMySQLConnection class, it calls self._open_connection() in abstract.py
  2. Inside _open_connection, it calls self._cmysql.connect(**cnx_kwargs) (connection_cext.py) which crashes my application.

I would appreciate if someone could provide some insights regarding this issue. Why would it work on some PC’s and not work on other PC’s?

Additionally, I have tried to confirm if the PC can reach the application and tried to run very simple MYSQL program :

import mysql.connector
from mysql.connector import Error



class mysql_db():
    def __init__(self):
        super().__init__()

    def DB_start(self,database, timeout=3):
        try:
            self.mydb = mysql.connector.connect(host="our_server.hostname.lt",user="root",password="password",database=database,connection_timeout = timeout)
        except mysql.connector.Error as err:
            print(f"mydb failed: {err}")
            return 0
        print("Connected to DB OK")
        return 1

mysql_db = mysql_db()
mysql_db.DB_start("OUR_DB")

and it works without any issues. However, when I try to connect to my DB from within my PySide6 application, it crashes



You need to sign in to view this answers

Exit mobile version