Example #1
0
    def query(sql, client=None, hostname='localhost', port=47470,
              username='******', password='******', pandas=True):
        """
        Run an sql query against Dremio and return a pandas dataframe or arrow table

        Either host,port,user,pass tuple or a pre-connected client should be supplied. Not both

        :param sql: sql query to execute on dremio
        :param client: pre-connected client (optional)
        :param hostname: Dremio coordinator hostname (optional)
        :param port: Dremio coordinator port (optional)
        :param username: Username on Dremio (optional)
        :param password: Password on Dremio (optional)
        :param pandas: return a pandas dataframe (default) or an arrow table
        :return:
        """
        if not client:
            client = connect(hostname, port, username, password)

        info = client.get_flight_info(flight.FlightDescriptor.for_command(tobytes(sql)))
        reader = client.do_get(info.endpoints[0].ticket)
        batches = []
        while True:
            try:
                batch, _ = reader.read_chunk()
                batches.append(batch)
            except StopIteration:
                break
        data = pa.Table.from_batches(batches)
        if pandas:
            return data.to_pandas()
        else:
            return data
Example #2
0
 def authenticate(self, outgoing, incoming):
     buf = incoming.read()
     auth = flight.BasicAuth.deserialize(buf)
     if auth.username not in self.creds:
         raise flight.FlightUnauthenticatedError("unknown user")
     if self.creds[auth.username] != auth.password:
         raise flight.FlightUnauthenticatedError("wrong password")
     outgoing.write(tobytes(auth.username))
Example #3
0
 def __init__(self, username, password):
     super(HttpBasicClientAuthHandler, self).__init__()
     self.username = tobytes(username)
     self.password = tobytes(password)
Example #4
0
 def __init__(self, username, password):
     super().__init__()
     self.username = tobytes(username)
     self.password = tobytes(password)
 def __init__(self, username, password):
     ClientAuthHandler.__init__(self)
     self.username = tobytes(username)
     self.password = tobytes(password)
     self.token = None
Example #6
0
 def __init__(self, username, password):
     super().__init__()
     self.username = tobytes(username)
     self.password = tobytes(password)