How to create connection to MySQL database with Python

1 Answer

0 votes
# c:\Users\user_nm\AppData\Local\Programs\Python\Python35-32\Scripts\pip install mysql-connector

import mysql.connector

db = mysql.connector.connect(
    host="localhost",
    user="root",
    passwd=""
)

print(db)
print(db.connection_id)


'''
run:

<mysql.connector.connection.MySQLConnection object at 0x0152D4D0>
28

'''

 



answered Nov 27, 2018 by avibootz
edited Nov 27, 2018 by avibootz

Related questions

1 answer 170 views
1 answer 161 views
1 answer 149 views
149 views asked Nov 27, 2018 by avibootz
...