Skip to content

Commit 1f37605

Browse files
committed
62. 修改增删改查.md
1 parent e540115 commit 1f37605

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Python中的MySQL/1.4增删改查.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import pymysql
1212
try:
1313
conn = pymysql.connect(host = 'localhost', port = 3306, db = 'Persons', user = 'root', password = 'password', charset = 'utf8')
1414
cursor = conn.cursor()
15-
cursor.execute('SELECT * FROM Persons')
15+
cursor.execute('SELECT * FROM Persons;')
1616
result = cursor.fetchall()
1717
print(result)
1818
cursor.close()
@@ -40,7 +40,7 @@ import pymysql
4040
try:
4141
conn = pymysql.connect(host = 'localhost', port = 3306, db = 'Persons', user = 'root', password = 'password', charset = 'utf8')
4242
cursor = conn.cursor()
43-
cursor.execute('UPDATE Persons SET CITY = 'Shanghai' WHERE ID_P = 1')
43+
cursor.execute('UPDATE Persons SET CITY = 'Shanghai' WHERE ID_P = 1;')
4444
conn.commit()
4545
cursor.close()
4646
conn.close()
@@ -60,7 +60,7 @@ import pymysql
6060
try:
6161
conn = pymysql.connect(host = 'localhost', port = 3306, db = 'Persons', user = 'root', password = 'password', charset = 'utf8')
6262
cursor = conn.cursor()
63-
cursor.execute("INSERT INTO Persons VALUES (DEFAULT, 'Bush', 'John', 'Changan Street', 'Beijing')")
63+
cursor.execute("INSERT INTO Persons VALUES (DEFAULT, 'Bush', 'John', 'Changan Street', 'Beijing');")
6464
conn.commit()
6565
cursor.close()
6666
conn.close()
@@ -80,7 +80,7 @@ import pymysql
8080
try:
8181
conn = pymysql.connect(host = 'localhost', port = 3306, db = 'Persons', user = 'root', password = 'password', charset = 'utf8')
8282
cursor = conn.cursor()
83-
cursor.execute("DELETE FROM Persons WHERE ID_P = 4")
83+
cursor.execute("DELETE FROM Persons WHERE ID_P = 4;")
8484
conn.commit()
8585
cursor.close()
8686
conn.close()

0 commit comments

Comments
 (0)