In this example we will show how to create a connection to the database in Python.
Source Code
import mysql.connector
# connect to server
mydb = mysql.connector.connect(
host="localhost",
port=3306,
user="yourusername",
password="yourpassword"
)
print(mydb)
Output:
<mysql.connector.connection.MySQLConnection object at 0x015EA150>