1 Star 1 Fork 1

hamagesila/pythonProject2248

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
test01_connect.py 402 Bytes
Copy Edit Raw Blame History
hamagesila authored 2022-04-28 21:57 . Initial commit djaksldjkals
# 导包
#
import pymysql
# 创建链接
conn = pymysql.connect(
host = "localhost",
port = 3306,
user = "root",
password = "root",
database = "books"
)
#
# 获取游标
cursor1 = conn.cursor()
#
# 执行sql
cursor1.execute("select version()")
result = cursor1.fetchall() # 拿取全部数据回来
print(result)
#
# 关闭游标
cursor1.close()
#
# 关闭连接
conn.close()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hamagesila/pythonProject2248.git
git@gitee.com:hamagesila/pythonProject2248.git
hamagesila
pythonProject2248
pythonProject2248
master

Search