コード例 #1
0
 def _root_local_sql(self):
     engine = init_engine(user, password, instance_info.user_ip)
     client = LocalSqlClient(engine)
     with client:
         t = text("""SELECT User, Host FROM mysql.user WHERE User=:user AND Host=:host;""")
         result = client.execute(t, user=user, host=host)
         for row in result:
             assert_equal(user, row['User'])
             assert_equal(host, row['Host'])
     root_password = password
     self.root_enabled_timestamp = self.dbaas_admin.management.show(instance_info.id).root_enabled_at
     assert_not_equal(self.root_enabled_timestamp, 'Never')
コード例 #2
0
 def _root_local_sql(self):
     engine = init_engine(user, password, instance_info.user_ip)
     client = LocalSqlClient(engine)
     with client:
         t = text("""SELECT User, Host FROM mysql.user """
                  """WHERE User=:user AND Host=:host;""")
         result = client.execute(t, user=user, host=host)
         for row in result:
             assert_equal(user, row['User'])
             assert_equal(host, row['Host'])
     root_password = password
     reh = self.dbaas_admin.management.root_enabled_history
     self.root_enabled_timestamp = reh(instance_info.id).enabled
     assert_not_equal(self.root_enabled_timestamp, 'Never')
コード例 #3
0
class MySqlConnection(object):

    def __init__(self, host):
        self.host = host

    def connect(self):
        """Connect to MySQL database."""
        self.client = LocalSqlClient(util.init_engine(
            MYSQL_USERNAME, MYSQL_PASSWORD, self.host), use_flush=False)

    def is_connected(self):
        try:
            with self.client:
                self.client.execute(text("""SELECT "Hello.";"""))
            return True
        except (sqlalchemy_exc.OperationalError,
                sqlalchemy_exc.DisconnectionError,
                sqlalchemy_exc.TimeoutError):
            return False
        except Exception as ex:
            print("EX WAS:")
            print(type(ex))
            print(ex)
            raise ex
コード例 #4
0
 def connect(self):
     """Connect to MySQL database."""
     self.client = LocalSqlClient(util.init_engine(
         MYSQL_USERNAME, MYSQL_PASSWORD, self.host), use_flush=False)