变更
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from pymysql import Connection
|
||||
|
||||
conn = Connection(
|
||||
host="localhost",
|
||||
port=3306,
|
||||
user="root",
|
||||
password="123123",
|
||||
autocommit=True # 自动确认
|
||||
)
|
||||
|
||||
# print(conn.get_server_info())
|
||||
|
||||
# 执行非查询性质SQL
|
||||
cursur = conn.cursor() # 获取游标对象
|
||||
# 选择数据库
|
||||
conn.select_db("world")
|
||||
# 执行sql
|
||||
# cursur.execute("create table test_pymysql(id int);")
|
||||
|
||||
# cursur.execute("select * from student")
|
||||
# result = cursur.fetchall()
|
||||
# print(result) # 返回类型为元组
|
||||
|
||||
# 提交数据
|
||||
cursur.execute("insert into student values(1,'李白',34)")
|
||||
# 提交数据
|
||||
# conn.commit()
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user