[Python] python mysql.connector does not throw any error or message, only exit from application

Discussão em 'Python' iniciado por Stack, Março 7, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to connect my localhost mysql server. My personel computer succusfully connect to mysql server with tis python code:

    import mysql.connector
    from mysql.connector import Error

    class DatabaseHelper():
    def __init__(self):
    self.host = "localhost"
    self.user = "root"
    self.password = "mysql"
    self.database = "temperedglassdb"
    self.db = None

    def connectDb(self):
    try:
    print("Started")
    if not self.isConnected():
    self.db = mysql.connector.connect(
    host = self.host,
    user = self.user,
    password = self.password,
    database = self.database)
    print("Finished")
    print(self.db)
    except Error as e:
    print(e)

    def isConnected(self):
    if self.db is not None:
    return self.db.is_connected()
    else:
    return False

    if __name__ == "__main__":
    db = DatabaseHelper()
    db.connectDb()


    Prints ->

    Started


    But on my work computer which has many organizational restriction. I could not connect to localhost mysql server on it. And this code does not throws any warning or error or any message to resolve the issue?

    [​IMG]

    How do i learn which problems is occours?

    Continue reading...

Compartilhe esta Página