Study Notes (24): 21 days clearance Python (Video Lesson only) - execute DML statements

Learning immediately: https://edu.csdn.net/course/play/24797/282204?utm_source=blogtoedu

'' ' 
SQL: Structured Query Language Structured Query Language 

DQL: Data Query Language data query language, such as select * from table name 

DDL: Aata Defintion Language Data Definition Language the Create, the ALTER, drop 

DML: the Data Manipulation Language Data Manipulation Language updata, instert, the Delete 
'' ' 
Import sqlite3 

# #insert INTO 
# conn = sqlite3.connect (' test51.db ') 
# CN = conn.cursor () 
# 
# cn.Execute (' INSERT INTO user_tb values (null,?,? ,?) ', (' Python ',' Python ', 7)) 
# cn.Execute (' INSERT INTO user_tb values (null,?,?,?) ', (' the .NET ',' the .NET ', 10 )) 
# Print (cn.rowcount) 
# conn.commit () 
# 
# cn.Close () 
# conn.Close () 

# # Update  
# = the sqlite3 Conn.connect('test51.db')
# = CN Conn.cursor()
#
# cn.execute('update user_tb set age=? where _id=?', (99, 2))
# cn.execute('update user_tb set age=? where _id=?', (77, 1,))
# print('结果集:', cn.rowcount)
# conn.commit()
#
# cn.close()
# conn.close()

# # del
# conn = sqlite3.connect('test51.db')
# cn = conn.cursor()
#
# cn.execute('delete from user_tb where _id=?', (2,))
# print('结果集:', cn.rowcount)
# conn.commit()
#
# cn.close()
# conn.close()

# #insert into
conn = sqlite3.connect('test51.db')
cn = conn.cursor()

cn.executemany('insert into user_tb values(null,?,?,?)',
               (('python', 'python', 1),
               ('java, java ', 2)
               ( 'Python', 'Python',. 3))) 
Print ( 'result set:', cn.rowcount) 
conn.commit () 

cn.Close () 
conn.Close ()
Published 39 original articles · won praise 29 · views 904

Guess you like

Origin blog.csdn.net/happyk213/article/details/105227952