Exemplo n.º 1
0
class MySqlConnection(object):

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

    def connect(self):
        """Connect to MySQL database."""
        print("Connecting to MySQL, mysql --host %s -u %s -p%s"
              % (self.host, MYSQL_USERNAME, MYSQL_PASSWORD))
        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
class MySqlConnection(object):

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

    def connect(self):
        """Connect to MySQL database."""
        print("Connecting to MySQL, mysql --host %s -u %s -p%s"
              % (self.host, MYSQL_USERNAME, MYSQL_PASSWORD))
        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
Exemplo n.º 3
0
 def connect(self):
     """Connect to MySQL database."""
     print("Connecting to MySQL, mysql --host %s -u %s -p%s" %
           (self.host, MYSQL_USERNAME, MYSQL_PASSWORD))
     self.client = LocalSqlClient(util.init_engine(MYSQL_USERNAME,
                                                   MYSQL_PASSWORD,
                                                   self.host),
                                  use_flush=False)
 def connect(self):
     """Connect to MySQL database."""
     print("Connecting to MySQL, mysql --host %s -u %s -p%s"
           % (self.host, MYSQL_USERNAME, MYSQL_PASSWORD))
     self.client = LocalSqlClient(util.init_engine(
         MYSQL_USERNAME, MYSQL_PASSWORD, self.host), use_flush=False)