示例#1
0
    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
示例#2
0
    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
示例#3
0
    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
示例#4
0
    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
示例#5
0
    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
示例#6
0
    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