创建与数据库的连接

  1. import mysql.connector
  2.  
  3. mydb = mysql.connector.connect(
  4. host="localhost",
  5. user="myusername",
  6. passwd="mypassword"
  7. )
  8.  
  9. print(mydb)