Get the App
SLTechnology News&Howtos  ›  Database  › 

Introduction to the basic usage of python-pymysql

Shulou Source: shulou.com Published: 2022-06-01 20:51:34 09月18日 Update

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.

Tags: In line industry engineering engineer technology experience query answer line following specialty thing book interest place practice cursor theory industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia MySQL vpn Docker