| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | import sqlite3 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 22:17:21 +02:00
										 |  |  | con = sqlite3.connect(":memory:") | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | cur = con.cursor() | 
					
						
							| 
									
										
										
										
											2012-02-15 22:17:21 +02:00
										 |  |  | cur.execute("create table people (name_last, age)") | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | who = "Yeltsin" | 
					
						
							|  |  |  | age = 72 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 22:17:21 +02:00
										 |  |  | # This is the qmark style: | 
					
						
							|  |  |  | cur.execute("insert into people values (?, ?)", (who, age)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # And this is the named style: | 
					
						
							|  |  |  | cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-15 14:28:22 +00:00
										 |  |  | print(cur.fetchone()) |