Python MySQL-Connector: Error #2003

158 Views Asked by At

I'm making a PyGO-BOT, and going to make integration with MySQL. While connecting to the server, console gave me an error:

Traceback (most recent call last): File "F:/PyCharm/projects/vkbot/pygo.py", line 153, in 2003: Can't connect to MySQL server on 'nesdevelopment.xyz:3306' (10061 Подключение не установлено, т.к. конечный компьютер отверг запрос на подключение) connection.close() AttributeError: 'NoneType' object has no attribute 'close'

How to solve this problem?

1

There are 1 best solutions below

0
Franrey Saycon On

NoneType object means that the variable connection is defined to be None or you assigned a function that returns None. You are expecting an object with a defined .close() method which I assume is a MYSQLdb Connector object.

Check your declaration of connection. Watch out for NoneType usual cases like these:

connection = None
connection = function_that_returns_none()

Make sure you have something similar to this and it's on scope:

connection = MySQLdb.connect(...)