Ticket #1258: pymssql.patch
| File pymssql.patch, 1.6 kB (added by Cheng <czhang.cmu+web@gmail.com>, 4 years ago) |
|---|
-
pymssql.py
old new 197 197 x = "'" + string.replace(str(x), "'", "''") + "'" 198 198 elif type(x) in (types.IntType, types.LongType, types.FloatType): 199 199 pass 200 elif type(x) == types.BooleanType: 201 x = x and 1 or 0 200 202 elif x is None: 201 203 x = 'NULL' 202 204 elif hasattr(x, '__pg_repr__'): … … 225 227 226 228 def __init__(self, cnx): 227 229 self.__cnx = cnx 230 self.__autocommit = False 228 231 try: 229 232 self.__cnx.query("begin tran") 230 233 self.__cnx.fetch_array() … … 240 243 def commit(self): 241 244 if self.__cnx == None: 242 245 raise OperationalError, "invalid connection." 246 if self.__autocommit == True: 247 return 243 248 try: 244 249 self.__cnx.query("commit tran") 245 250 self.__cnx.fetch_array() … … 251 256 def rollback(self): 252 257 if self.__cnx == None: 253 258 raise OperationalError, "invalid connection." 259 if self.__autocommit == True: 260 return 254 261 try: 255 262 self.__cnx.query("rollback tran") 256 263 self.__cnx.fetch_array() … … 266 273 return pymssqlCursor(self.__cnx) 267 274 except: 268 275 raise OperationalError, "invalid connection." 276 277 def autocommit(self,status): 278 if status: 279 if self.__autocommit == False: 280 self.__cnx.query("rollback tran") 281 self.__cnx.fetch_array() 282 self.__autocommit = True 283 else: 284 if self.__autocommit == True: 285 self.__cnx.query("begin tran") 286 self.__cnx.fetch_array() 287 self.__autocommit = False 269 288 270 289 271 272 290 # connects to a database 273 291 def connect(dsn = None, user = "sa", password = "", host = "127.0.0.1", database = "master"): 274 292 # first get params from DSN
