Пример #1
0
class TornadoConnection(BaseConnection):
    def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, configuration=None):
        super(TornadoConnection, self).__init__(authMechanism)
        #Must set a password for thrift, even if it doesn't need one
        #Open issue with python-sasl
        password = self._check_password(authMechanism, password)
        if authMechanism == "NOSASL":
            self.transport = TTornadoStreamTransport(host, port)
        else:
            saslc, sasl_mech = self._get_sasl_client(host, authMechanism, user, password, configuration)
            self.transport = TSaslClientTransportTornado(saslc, sasl_mech, host, port)
        pfactory = TBinaryProtocolFactory()
        self.client = TCLIServiceTornado.Client(self.transport, pfactory)

    @gen.engine
    def connect(self, database, configuration, callback):
        yield gen.Task(self.transport.open)
        req = TOpenSessionReqTornado(configuration=configuration)
        res = yield gen.Task(self.client.OpenSession, req)
        self.session = res.sessionHandle
        if database is not None:
            query = "USE {0}".format(database)
            yield gen.Task(self.cursor().execute, query)
        callback()

    @gen.engine
    def close(self, callback):
        req = TCloseSessionReqTornado(sessionHandle=self.session)
        yield gen.Task(self.client.CloseSession, req)
        self.transport.close()
        callback()

    def cursor(self):
        return TornadoCursor(self.client, self.session)
Пример #2
0
 def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, configuration=None):
     super(TornadoConnection, self).__init__(authMechanism)
     #Must set a password for thrift, even if it doesn't need one
     #Open issue with python-sasl
     password = self._check_password(authMechanism, password)
     if authMechanism == "NOSASL":
         self.transport = TTornadoStreamTransport(host, port)
     else:
         saslc, sasl_mech = self._get_sasl_client(host, authMechanism, user, password, configuration)
         self.transport = TSaslClientTransportTornado(saslc, sasl_mech, host, port)
     pfactory = TBinaryProtocolFactory()
     self.client = TCLIServiceTornado.Client(self.transport, pfactory)
Пример #3
0
class TornadoConnection(BaseConnection):
    def __init__(self,
                 host=None,
                 port=10000,
                 authMechanism=None,
                 user=None,
                 password=None,
                 configuration=None):
        super(TornadoConnection, self).__init__(authMechanism)
        #Must set a password for thrift, even if it doesn't need one
        #Open issue with python-sasl
        password = self._check_password(authMechanism, password)
        if authMechanism == "NOSASL":
            self.transport = TTornadoStreamTransport(host, port)
        else:
            saslc, sasl_mech = self._get_sasl_client(host, authMechanism, user,
                                                     password, configuration)
            self.transport = TSaslClientTransportTornado(
                saslc, sasl_mech, host, port)
        pfactory = TBinaryProtocolFactory()
        self.client = TCLIServiceTornado.Client(self.transport, pfactory)

    @gen.engine
    def connect(self, database, configuration, callback):
        yield gen.Task(self.transport.open)
        req = TOpenSessionReqTornado(configuration=configuration)
        res = yield gen.Task(self.client.OpenSession, req)
        self.session = res.sessionHandle
        if database is not None:
            query = "USE {0}".format(database)
            yield gen.Task(self.cursor().execute, query)
        callback()

    @gen.engine
    def close(self, callback):
        req = TCloseSessionReqTornado(sessionHandle=self.session)
        yield gen.Task(self.client.CloseSession, req)
        self.transport.close()
        callback()

    def cursor(self):
        return TornadoCursor(self.client, self.session)
Пример #4
0
 def __init__(self,
              host=None,
              port=10000,
              authMechanism=None,
              user=None,
              password=None,
              configuration=None):
     super(TornadoConnection, self).__init__(authMechanism)
     #Must set a password for thrift, even if it doesn't need one
     #Open issue with python-sasl
     password = self._check_password(authMechanism, password)
     if authMechanism == "NOSASL":
         self.transport = TTornadoStreamTransport(host, port)
     else:
         saslc, sasl_mech = self._get_sasl_client(host, authMechanism, user,
                                                  password, configuration)
         self.transport = TSaslClientTransportTornado(
             saslc, sasl_mech, host, port)
     pfactory = TBinaryProtocolFactory()
     self.client = TCLIServiceTornado.Client(self.transport, pfactory)