import mysql.connector as con # 获取游标 def connect_db(dbname,username,password): cons = con.connect(user = username, password = password, database = dbname) return cons