Python Forum

Full Version: Issues with MySql Connection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import mysql.connector

mydb = mysql.connector.connect(
    host="localhost",
    user="EMG",
    password="JAMESPaige@63"
)

print("Connected to MySQL database:", mydb.database)
been trying to run this script to connect to a MySQL Database I am trying to set up with python, it has flagged an issue with no attribute with 'connect' on line 3 which I cant get as I've all the right libraries installed. Coming at this like a beginner as I haven't used Python in 5 years
I recommend reading this article for oython and mysql databases.
https://realpython.com/python-mysql/
Thank you so much :-)