mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 10:26:02 +00:00 
			
		
		
		
	 287b84de93
			
		
	
	
		287b84de93
		
	
	
	
	
		
			
			The sqlit3.Connection object doesn't call its close() method when it's used as a context manager.
		
			
				
	
	
		
			18 lines
		
	
	
	
		
			347 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
	
		
			347 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import sqlite3
 | |
| 
 | |
| con = sqlite3.connect("mydb")
 | |
| 
 | |
| cur = con.cursor()
 | |
| 
 | |
| newPeople = (
 | |
|     ('Lebed'       , 53),
 | |
|     ('Zhirinovsky' , 57),
 | |
|   )
 | |
| 
 | |
| for person in newPeople:
 | |
|     cur.execute("insert into people (name_last, age) values (?, ?)", person)
 | |
| 
 | |
| # The changes will not be saved unless the transaction is committed explicitly:
 | |
| con.commit()
 | |
| 
 | |
| con.close()
 |