mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	 db20afe6c4
			
		
	
	
		db20afe6c4
		
			
		
	
	
	
	
		
			
			(cherry picked from commit 92d1064727)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
		
	
			
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			540 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			540 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import sqlite3
 | |
| 
 | |
| con = sqlite3.connect(":memory:")
 | |
| cur = con.cursor()
 | |
| cur.execute("create table lang (name, first_appeared)")
 | |
| 
 | |
| # This is the qmark style:
 | |
| cur.execute("insert into lang values (?, ?)", ("C", 1972))
 | |
| 
 | |
| # The qmark style used with executemany():
 | |
| lang_list = [
 | |
|     ("Fortran", 1957),
 | |
|     ("Python", 1991),
 | |
|     ("Go", 2009),
 | |
| ]
 | |
| cur.executemany("insert into lang values (?, ?)", lang_list)
 | |
| 
 | |
| # And this is the named style:
 | |
| cur.execute("select * from lang where first_appeared=:year", {"year": 1972})
 | |
| print(cur.fetchall())
 | |
| 
 | |
| con.close()
 |