Python Forum
MySql connection problem - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Networking (https://python-forum.io/forum-12.html)
+--- Thread: MySql connection problem (/thread-29695.html)



MySql connection problem - KDN - Sep-16-2020

Hi,

I am trying to connect MySql using python, but it's showing error.


Error:
Traceback (most recent call last): File "/home/ai/Documents/Database/mysql.py", line 1, in <module> import mysql.connector File "/home/ai/Documents/Database/mysql.py", line 1, in <module> import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package
I try to install pip3 mysql.connector also but after installing it's now working and showing same error.


RE: MySql connection problem - micseydel - Sep-16-2020

I would guess that's because Python is trying to import mysql, which is your file name, so I think it's trying to import itself. If you change the name of your file, you should be fine. Be careful of overriding your imports with local file names :)