You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
556 B
25 lines
556 B
# -*- encoding: utf-8 -*-
|
|
'''
|
|
@File : mysql_conn2.py
|
|
@License : (C)Copyright 2018-2022
|
|
|
|
@Modify Time @Author @Version @Desciption
|
|
------------ ------- -------- -----------
|
|
2023/4/16 18:13 zart20 1.0 None
|
|
'''
|
|
|
|
# mysql-connector-python 链接示例
|
|
|
|
import mysql.connector
|
|
|
|
db = mysql.connector.connect(host="127.0.0.1", port=3306, user='root', password="123123", charset="utf8", database="student")
|
|
|
|
cursor = db.cursor()
|
|
|
|
cursor.execute("show databases;")
|
|
|
|
data = cursor.fetchall()
|
|
|
|
print(data)
|
|
|
|
cursor.close() |