1import mysql.connector
2
3cnx = mysql.connector.connect(user='scott', password='password',
4 host='127.0.0.1',
5 database='employees')
6cnx.close()
1import mysql.connector
2mydb = mysql.connector.connect(
3 host="localhost",
4 user="yourusername",
5 password="yourpassword",
6 port = 8888, #for Mamp users
7 database='whatever db you want'
8)
9print(mydb)
1from sqlalchemy import types, create_engine
2import pymysql
3
4try:
5 conn = create_engine('mysql+pymysql://user:pass@IP/database_name')
6 print("MySQL Connection Sucessfull!!!!!!!!!!!")
7
8except Exception as err:
9
10 print("MySQL Connection Failed !!!!!!!!!!!")
11 print(err)
12