def saveChanges(self): conn, cur = self.connectionAndCursor() try: SQLObjectStore.saveChanges(self) except DatabaseError: conn.rollback() raise except Warning: if not self.setting('IgnoreSQLWarnings', False): conn.rollback() raise conn.commit()
def setting(self, name, default=NoDefault): # jdh: psycopg doesn't seem to work well with DBPool -- I've experienced # requests blocking indefinitely (deadlock?). Besides, it does its # own connection pooling internally, so DBPool is unnecessary. if name == 'SQLConnectionPoolSize': return 0 return SQLObjectStore.setting(self, name, default)
def connect(self): SQLObjectStore.connect(self) if self._autocommit: # Since our autocommit patch above does not get applied to pooled # connections, we have to monkey-patch the pool connection method try: pool = self._pool connection = pool.connection except AttributeError: pass else: def newConnection(self): conn = self._normalConnection() try: conn.autocommit(True) except AttributeError: pass return conn pool._normalConnection = connection pool._autocommit = self._autocommit pool.connection = new.instancemethod( newConnection, pool, pool.__class__)
def connect(self): SQLObjectStore.connect(self) if self._autocommit: # Since our autocommit patch above does not get applied to pooled # connections, we have to monkey-patch the pool connection method try: pool = self._pool connection = pool.connection except AttributeError: pass else: def newConnection(self): conn = self._normalConnection() try: conn.autocommit(True) except AttributeError: pass return conn pool._normalConnection = connection pool._autocommit = self._autocommit pool.connection = new.instancemethod(newConnection, pool, pool.__class__)
def __init__(self, **kwargs): self._autocommit = kwargs.pop('autocommit', False) SQLObjectStore.__init__(self, **kwargs)
def setting(self, name, default=NoDefault): if name == 'SQLConnectionPoolSize': return 0 return SQLObjectStore.setting(self, name, default)
def setting(self, name, default=NoDefault): if name == 'SQLConnectionPoolSize': return 0 # pyodbc comes already with pooling return SQLObjectStore.setting(self, name, default)
def __init__(self, **kwargs): self._autocommit = kwargs.get('autocommit', True) SQLObjectStore.__init__(self, **kwargs)