MySQLdb_异常操作错误:(2002,“无法连接到‘localhost’(10048)”上的MySQL服务器)

2024-09-29 22:30:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用执行以下查询

        connection= MySQLdb.connect(host=self.__host, user=self.__db_username, passwd=self.__db_passwd, db=self.__db, charset="utf8", use_unicode=True)
        cursor= connection.cursor()
        sql= 'SELECT * FROM func1'
        cursor.execute(sql)
        data= cursor.fetchall()
        cursor.close()
        connection.close()
        func1 = None

        if len(data)>0:
            func1s = []
            for item in data:
                func1= db_func1()
                #item = data[0]
                func1.id = item[0]
                func1.title = item[2]


                func1s.append(func1)
            return func1s

这是第一次,它将被执行,但过了一秒它就会给我错误,我使用的是3306端口

谢谢你的帮助

^{pr2}$

Tags: selfhostclosedbsqldataconnectconnection

热门问题