Skip to content

Instantly share code, notes, and snippets.

@narendrans
Created July 19, 2019 22:15
Show Gist options
  • Save narendrans/023173ed1131e3cb5243bbeb70058953 to your computer and use it in GitHub Desktop.
Save narendrans/023173ed1131e3cb5243bbeb70058953 to your computer and use it in GitHub Desktop.
from pyarrow import flight
import base64,time,pandas
class HttpDremioClientAuthHandler(flight.ClientAuthHandler):
def __init__(self, username, password):
super().__init__()
self.username = bytes(username)
self.password = bytes(password)
self.token = None
def authenticate(self, outgoing, incoming):
outgoing.write(base64.b64encode(self.username + b':' + self.password))
self.token = incoming.read()
def get_token(self):
return self.token
c = flight.FlightClient.connect('grpc+tcp://localhost:47470')
c.authenticate(HttpDremioClientAuthHandler(b'dremio',b'dremio123'))
sql = 'SELECT 1'
df = c.do_get(c.get_flight_info(flight.FlightDescriptor.for_command(sql)).endpoints[0].ticket).read_all().to_pandas()
print(df.to_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment