コード例 #1
0
ファイル: persistence.py プロジェクト: yoku0825/mikasafabric
    def setup(cls):
        """Setup the object persistance system.

        Perform initialization, which in this case means creating
        the database if it does not exist.
        """
        assert (cls.connection_info is not None)
        conn = connect_to_mysql(autocommit=True, **cls.connection_info)
        exec_mysql_stmt(
            conn, "CREATE DATABASE %s DEFAULT CHARSET=utf8" % (cls.database, ))
コード例 #2
0
ファイル: persistence.py プロジェクト: yoku0825/mikasafabric
    def teardown(cls):
        """Tear down the object persistance system.

        This should only be called if the persistance database should
        be removed from the persistance server since it will delete
        all object tables.
        """
        assert (cls.connection_info is not None)
        conn = connect_to_mysql(autocommit=True, **cls.connection_info)
        exec_mysql_stmt(conn, "DROP DATABASE IF EXISTS %s" % (cls.database, ))
コード例 #3
0
    def setup(cls):
        """Setup the object persistance system.

        Perform initialization, which in this case means creating
        the database if it does not exist.
        """
        assert (cls.connection_info is not None)
        conn = _server_utils.create_mysql_connection(autocommit=True,
                                                     use_unicode=True,
                                                     **cls.connection_info)
        _server_utils.exec_mysql_stmt(conn,
                                      "CREATE DATABASE %s" % (cls.database, ))
コード例 #4
0
    def setup(cls):
        """Setup the object persistance system.

        Perform initialization, which in this case means creating
        the database if it does not exist.
        """
        assert (cls.connection_info is not None)
        conn = connect_to_mysql(
            autocommit=True, **cls.connection_info
        )
        exec_mysql_stmt(
            conn, "CREATE DATABASE %s DEFAULT CHARSET=utf8" % (cls.database, )
        )
コード例 #5
0
    def setup(cls):
        """Setup the object persistance system.

        Perform initialization, which in this case means creating
        the database if it does not exist.
        """
        assert (cls.connection_info is not None)
        conn = _server_utils.create_mysql_connection(
            autocommit=True, use_unicode=False, **cls.connection_info
        )
        _server_utils.exec_mysql_stmt(
            conn, "CREATE DATABASE %s" % (cls.database, )
        )
コード例 #6
0
    def teardown(cls):
        """Tear down the object persistance system.

        This should only be called if the persistance database should
        be removed from the persistance server since it will delete
        all object tables.
        """
        assert (cls.connection_info is not None)
        conn = connect_to_mysql(
            autocommit=True, **cls.connection_info
        )
        exec_mysql_stmt(
            conn, "DROP DATABASE IF EXISTS %s" % (cls.database, )
        )
コード例 #7
0
 def max_allowed_connections(self):
     """Return the maximum number of allowed connections to server.
     """
     row = exec_mysql_stmt(
         self.__cnx, "SELECT @@GLOBAL.max_connections"
     )
     return int(row[0][0])
コード例 #8
0
ファイル: persistence.py プロジェクト: mgsanusi/DeepChrome
 def max_allowed_connections(self):
     """Return the maximum number of allowed connections to server.
     """
     row = exec_mysql_stmt(
         self.__cnx, "SELECT @@GLOBAL.max_connections"
     )
     return int(row[0][0])
コード例 #9
0
ファイル: persistence.py プロジェクト: yoku0825/mikasafabric
    def uuid(self):
        """Return the MySQLPersister's UUID if the server supports it.
        Otherwise, return None.
        """
        try:
            row = exec_mysql_stmt(self.__cnx, "SELECT @@GLOBAL.SERVER_UUID")
            return _uuid.UUID(str(row[0][0]))
        except _errors.DatabaseError:
            pass

        return None
コード例 #10
0
    def uuid(self):
        """Return the MySQLPersister's UUID if the server supports it.
        Otherwise, return None.
        """
        try:
            row = exec_mysql_stmt(
                self.__cnx, "SELECT @@GLOBAL.SERVER_UUID"
            )
            return _uuid.UUID(str(row[0][0]))
        except _errors.DatabaseError:
            pass

        return None
コード例 #11
0
ファイル: persistence.py プロジェクト: yoku0825/mikasafabric
    def exec_stmt(self, stmt_str, options=None):
        """Execute statements against the server.

        If a new transaction is about to be started, this method checks whether
        the connection is valid or not. If the connection is invalid, it tries
        to restablish it as MySQL might disconnect inactive connections.

        See :meth:`~mysql.fabric.server_utils.exec_stmt`.
        """
        while True:
            if self.__check_connection and \
                not is_valid_mysql_connection(self.__cnx):
                self._try_to_fix_connection()
            return exec_mysql_stmt(self.__cnx, stmt_str, options)
コード例 #12
0
ファイル: persistence.py プロジェクト: yoku0825/mikasafabric
    def event_scheduler(self):
        """Return the event_scheduler's setting.
        """
        try:
            row = exec_mysql_stmt(self.__cnx,
                                  "SELECT @@GLOBAL.EVENT_SCHEDULER")

            if row[0][0] == "ON":
                return True
            else:
                return False
        except _errors.DatabaseError:
            pass

        return None
コード例 #13
0
    def exec_stmt(self, stmt_str, options=None):
        """Execute statements against the server.

        If a new transaction is about to be started, this method checks whether
        the connection is valid or not. If the connection is invalid, it tries
        to restablish it as MySQL might disconnect inactive connections.

        See :meth:`~mysql.fabric.server_utils.exec_stmt`.
        """
        while True:
            if self.__check_connection and \
                not is_valid_mysql_connection(self.__cnx):
                self._try_to_fix_connection()
            return exec_mysql_stmt(
                self.__cnx, stmt_str, options
            )
コード例 #14
0
ファイル: persistence.py プロジェクト: gmo-media/mikasafabric
    def event_scheduler(self):
        """Return the event_scheduler's setting.
        """
        try:
            row = exec_mysql_stmt(
                self.__cnx, "SELECT @@GLOBAL.EVENT_SCHEDULER"
            )

            if row[0][0] == "ON":
              return True
            else:
              return False
        except _errors.DatabaseError:
            pass

        return None