Python connected to mysql successfully. After executing the insert command, there is no value in the table in mysql.

first of all, I created a database, called dd in mysal, and then I created a table, called books in it, and then I executed the following command in python, hoping to insert a value in books:

< hr >
import pymysql
conn=pymysql.connect (host= "127.0.0.1", port=3306, user= "root", passwd= "", db= "dd")
sql= "insert into books (title,link,comment) values ("a penalty for banners,"
conn.query (sql)
1

because this is executed directly in python"s shell, does the last appearance of 1 indicate that the execution has been successful? But I then queried the contents of books in mysql but did not have an inserted value (a _
in addition, I went directly to mysql to run insert into books (title,link,comment) values ("1 # 2 # 3"), and then queried it and got the inserted value. Excuse me, is there something wrong with my previous operation in python? If it"s wrong, why does it end up with 1 instead of 0? How should I modify it?

Mar.07,2021

commit submit. Or use the with statement instead.
never read tutorials or documentation?


see python/python-mysql.html" rel=" nofollow noreferrer "> http://www.runoob.com/python/. here the python operation mysql is written in great detail

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea4ef2-1d19.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea4ef2-1d19.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?