当前位置:网站首页>MySQL pymysql operation
MySQL pymysql operation
2022-07-28 02:14:00 【Dark horse programmer official】
MySQL Strong performance , It is one of the most widely used databases at present , With MySQL For learning the prototype, it is also convenient to master other databases later , Now let's give you Give a comprehensive explanation MySQL8.0 New features , From zero foundation to high-level one-stop learning , Combined with actual cases, we can gain something !
▼ MySQL8.0 introduction - Advanced learning notes :( It's over )
- The first 1 speak :SQL Overview and database system introduction
- The first 2 speak :MySQL brief introduction 、 Detailed installation steps and use
- The first 3 speak :MySQL Common graphics management tools
- The first 4 speak :MySQL Basic operation of database -DDL
- The first 5 speak :MySQL Basic operation of database -DML
- The first 6 speak :MySQL Classification of constraints 、 Function and usage
- The first 7 speak :MySQL Basic operation of database -DQL- The basic query
- The first 8 speak :MySQL Multi table operation of
- The first 9 speak :MySQL Aggregate functions 、 Date function 、 Window functions, etc
- The first 10 take :MySQL View introduction of 、 Create and other operations
- The first 11 speak :MySQL Stored procedure 、 Features and case exercises
- The first 12 speak :MySQL Triggers and other operations 、 matters needing attention
- The first 13 speak :MySQL The index of 、 classification 、 Characteristics, principles and related operations
- The first 14 speak :MySQL Storage engine classification and operation
- The first 15 speak :MySQL The business of 、 operation 、 Isolation level
- The first 16 speak :MySQL Lock mechanism :MyISAM Table locks 、InnoDB Row lock
- The first 17 speak :MySQL Classification of log : Error log 、 Binary log 、 Query log 、 Slow query log
- The first 18 speak :MySQL Optimization analysis and efficiency implementation of
- The first 19 speak :MySQL Of JDBC Operation and introduction cases
Use
PyMySQL It's pure. Python Realized MySQL Client library , Support compatibility Python 3, Used to replace MySQLdb..
import pymysql
conn = pymysql.connect(host='localhost', port=3306, user='root',password='123456',database='mydb17_pymysql', charset='utf8')
# To obtain the cursor
cursor = conn.cursor()
# perform SQL sentence The return value is SQL The number of lines affected by the statement during execution
sql = "select * from student;"
row_count = cursor.execute(sql)
print("SQL Number of rows affected by statement execution %d" % row_count)
# Fetch a row in the result set The result is a line
# print(cursor.fetchone())
# Take out all data in the result set Returns a row of data
for line in cursor.fetchall():
print(line)
# Close cursor
cursor.close()
# Close the connection
conn.close()
import pymysql
# obtain MySQL Connect
conn = pymysql.connect(host='localhost', port=3306, user='root',password='123456',database='mydb17_pymysql', charset='utf8')
# To obtain the cursor
cursor = conn.cursor()
# perform SQL sentence The return value is SQL The number of lines affected by the statement during execution
sql = "select * from student;"
row_count = cursor.execute(sql)
print("SQL Number of rows affected by statement execution %d" % row_count)
# Fetch a row in the result set The result is a line
# print(cursor.fetchone())
# Take out all data in the result set Returns a row of data
for line in cursor.fetchall():
print(line)
# Close cursor
cursor.close()
# Close the connection
conn.close()
import pymysql
# obtain MySQL Connect
conn = pymysql.connect(host='localhost', port=3306, user='root',password='123456',database='mydb17_pymysql', charset='utf8')
# To obtain the cursor
cursor = conn.cursor()
# insert data
# sql = "insert into student values(%s,%s,%s)"
# data = (4, ' Chaogai ', 34)
# cursor.execute(sql, data) #sql and data Between "," separate
# Modifying data
# sql = "update student set sname=%s where sid=%s"
# data = (' Li Kui ', 4)
# cursor.execute(sql, data)
# Delete data
sql = "delete from student where sid=%s"
data = (4)
cursor.execute(sql, data)
conn.commit() # Submit , Otherwise, the inserted or modified data cannot be saved ( Don't forget to add )
# Close cursor
cursor.close()
# Close the connection
conn.close()边栏推荐
- Software testing interview question: what is the purpose of test planning? What are the contents of the test plan? Which are the most important?
- 54:第五章:开发admin管理服务:7:人脸入库流程;人脸登录流程;浏览器开启视频调试模式(以便能够在本机的不安全域名的情况下,也能去开启摄像头);
- QGIS mapping: vector data mapping process and export
- Unittest unit test framework full stack knowledge
- Gbase 8C backup control function (III)
- Gbase 8C snapshot synchronization function
- Gbase 8C server signal function
- Use of classes in typescript
- SFTP file / folder upload server
- Codeforces Round #807 (Div. 2) A-C题解
猜你喜欢

Uniapp summary (applet)

Flume(5个demo轻松入门)

BGP federal experiment

QGIS制图:矢量数据制图流程及导出

一种比读写锁更快的锁,还不赶紧认识一下

Completely delete MySQL in Linux system

Unreal ue4.27 switchboard porting engine process

JS what situations can't use json Parse, json.stringify deep copy and a better deep copy method

Enterprise operation and maintenance practice - using aliyun container image service to pull and build images of overseas GCR and quay warehouses

Sample imbalance - entry 0
随机推荐
[website construction] update SSL certificate with acme.sh: change zerossl to letsencrypt
如何评估研发人员效能?软件工程师报告帮你看见每个人的贡献
shell正则和元字符
Domain Driven Design -- Terminology
Gbase 8C backup control function (III)
Shell regular and metacharacters
Comparison between hardware SPI and software analog SPI rate
Gbase 8C recovery control function
Codeworks round 810 (Div. 2) a~c problem solution
云原生爱好者周刊:Prometheus 架构演进之路
Huawei app UI automation test post interview real questions, real interview experience.
QGIS制图:矢量数据制图流程及导出
Common video resolution
Promise从入门到精通 (第2章 Promise的理解和使用)
Vxe table/grid cell grouping and merging
软件测试面试题:测试计划工作的目的是什么?测试计划工作的内容都包括什么?其中哪些是最重要的?
SFTP file / folder upload server
[Taichi] draw a regular grid in Tai Chi
[database data recovery] data recovery case of insufficient disk space of SQL Server database
记录一次生产死锁