mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	
		
			
	
	
		
			15 lines
		
	
	
	
		
			304 B
		
	
	
	
		
			Python
		
	
	
	
	
	
		
		
			
		
	
	
			15 lines
		
	
	
	
		
			304 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 
								 | 
							
								import sqlite3
							 | 
						||
| 
								 | 
							
								import datetime, time
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								def adapt_datetime(ts):
							 | 
						||
| 
								 | 
							
								    return time.mktime(ts.timetuple())
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								sqlite3.register_adapter(datetime.datetime, adapt_datetime)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								con = sqlite3.connect(":memory:")
							 | 
						||
| 
								 | 
							
								cur = con.cursor()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								now = datetime.datetime.now()
							 | 
						||
| 
								 | 
							
								cur.execute("select ?", (now,))
							 | 
						||
| 
								 | 
							
								print(cur.fetchone()[0])
							 |