Introduction to the basic usage of python-pymysql
The following brings you an introduction to the basic usage of python-pymysql, hoping to give you some help in practical application.
MYSQL involves a lot of things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
1. Basic usage
Import pymysql# establish connection conn=pymysql.connect (host='localhost', port=3306, user='root', password='123456', db='mydb') # create cursor cursor=conn.cursor () # execute sqleffect_row=cursor.execute ("select * from student") # query the first line # row_1=cursor.fetchone () # print (row_1) # query all row_all=cursor.fetchall () print (row_all) conn.commit () cursor.close ()
Conn.close ()
After reading the above introduction to the basic usage of python-pymysql, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional technical engineer to answer, the technical engineer has more than ten years of experience in the industry.