Detailed explanation of examples of executemany and sequence in python

黄舟
Release: 2017-08-13 09:51:26
Original
1993 people have browsed it

This article mainly introduces relevant information on the detailed explanation of the use of executemany and sequence in python. Friends in need can refer to the following

Detailed explanation of the use of executemany and sequence in python

One code


##

import sqlite3 
persons=[ 
  ("Jim","Green"), 
  ("Hu","jie") 
  ] 
conn=sqlite3.connect(":memory:") 
conn.execute("CREATE TABLE person(firstname,lastname)") 
conn.executemany("INSERT INTO person(firstname,lastname) VALUES(?,?)",persons) 
for row in conn.execute("SELECT firstname,lastname FROM person"): 
  print(row) 
   
print("I just deleted",conn.execute("DELETE FROM person").rowcount,"rows")
Copy after login

Two running results


y ========
('Jim', 'Green')
('Hu', 'jie')
I just deleted 2 rows
Copy after login

The above is the detailed content of Detailed explanation of examples of executemany and sequence in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template