Wed May 31 09:20:00 UTC 2023 inscode

上级 df352508
print('欢迎来到 InsCode')
\ No newline at end of file
import mysql.connector
config = {
'host': 'mysql.inscode.run',
'port': 3306,
'user': 'root',
'password': 'inscode'
}
# 连接到数据库
cnx = mysql.connector.connect(**config)
# 创建一个游标对象
cursor = cnx.cursor()
# 执行一些 SQL
cursor.execute('SHOW DATABASES')
# 获取结果集
for database in cursor:
print(database)
# 关闭游标和连接
cursor.close()
cnx.close()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册