def get_connection(self, autocommit = 0, isolation_level = I_DEFAULT): # autocommit overrider isolation_level if autocommit: if isolation_level == I_SERIALIZABLE: raise Exception('autocommit is not compatible with I_SERIALIZABLE') isolation_level = I_AUTOCOMMIT # default isolation_level is READ COMMITTED if isolation_level < 0: isolation_level = I_READ_COMMITTED # new conn? if not self.conn: self.isolation_level = isolation_level self.conn = connect_database(self.loc) self.conn.my_name = self.name self.conn.set_isolation_level(isolation_level) self.conn_time = time.time() if self.setup_func: self.setup_func(self.name, self.conn) else: if self.isolation_level != isolation_level: raise Exception("Conflict in isolation_level") # done return self.conn
def makeSocket(self): """Create server connection. In this case its not socket but database connection.""" db = connect_database(self.connect_string) db.set_isolation_level(0) # autocommit return db
def get_connection(self, autocommit=0, isolation_level=I_DEFAULT, listen_channel_list=[]): # autocommit overrider isolation_level if autocommit: if isolation_level == I_SERIALIZABLE: raise Exception( 'autocommit is not compatible with I_SERIALIZABLE') isolation_level = I_AUTOCOMMIT # default isolation_level is READ COMMITTED if isolation_level < 0: isolation_level = I_READ_COMMITTED # new conn? if not self.conn: self.isolation_level = isolation_level self.conn = connect_database(self.loc) self.conn.my_name = self.name self.conn.set_isolation_level(isolation_level) self.conn_time = time.time() if self.setup_func: self.setup_func(self.name, self.conn) else: if self.isolation_level != isolation_level: raise Exception("Conflict in isolation_level") self._sync_listen(listen_channel_list) # done return self.conn
def get_connection(self, autocommit = 0, isolation_level = -1): # autocommit overrider isolation_level if autocommit: isolation_level = I_AUTOCOMMIT # default isolation_level is READ COMMITTED if isolation_level < 0: isolation_level = I_READ_COMMITTED # new conn? if not self.conn: self.isolation_level = isolation_level self.conn = connect_database(self.loc) self.conn.set_isolation_level(isolation_level) self.conn_time = time.time() else: if self.isolation_level != isolation_level: raise Exception("Conflict in isolation_level") # done return self.conn