mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-10-30 23:37:29 +03:00 
			
		
		
		
	psycopg1 compatibility module (added autocommit.)
This commit is contained in:
		
							parent
							
								
									fdb68599c7
								
							
						
					
					
						commit
						728b4788de
					
				|  | @ -1,5 +1,8 @@ | ||||||
| 2005-04-03  Federico Di Gregorio  <fog@debian.org> | 2005-04-03  Federico Di Gregorio  <fog@debian.org> | ||||||
| 
 | 
 | ||||||
|  | 	* lib/psycopg1.py (connection.autocommit): added compatibility | ||||||
|  | 	.autocommit() method. | ||||||
|  | 
 | ||||||
| 	* psycopg/psycopgmodule.c (psyco_connect): factory -> | 	* psycopg/psycopgmodule.c (psyco_connect): factory -> | ||||||
| 	connection_factory. | 	connection_factory. | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -41,6 +41,13 @@ class connection(_2connection): | ||||||
|         """cursor() -> new psycopg 1.1.x compatible cursor object""" |         """cursor() -> new psycopg 1.1.x compatible cursor object""" | ||||||
|         return _2connection.cursor(self, cursor_factory=cursor) |         return _2connection.cursor(self, cursor_factory=cursor) | ||||||
| 
 | 
 | ||||||
|  |     def autocommit(self, on_off=1): | ||||||
|  |         """autocommit(on_off=1) -> switch autocommit on (1) or off (0)""" | ||||||
|  |         if on_off > 0: | ||||||
|  |             self.set_isolation_level(0) | ||||||
|  |         else: | ||||||
|  |             self.set_isolation_level(2) | ||||||
|  |              | ||||||
| 
 | 
 | ||||||
| class cursor(_2cursor): | class cursor(_2cursor): | ||||||
|     """psycopg 1.1.x cursor. |     """psycopg 1.1.x cursor. | ||||||
|  | @ -73,4 +80,4 @@ class cursor(_2cursor): | ||||||
|         for row in rows: |         for row in rows: | ||||||
|             res.append(self.__build_dict(row)) |             res.append(self.__build_dict(row)) | ||||||
|         return res |         return res | ||||||
|   | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user