Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import sys
  2. sys.path.insert(0,'./TCLIService')
  3. sys.path.insert(0,'./cloudera')
  4.  
  5. import TCLIService
  6. import ttypes
  7. from thrift import Thrift
  8. from thrift.transport import TSocket
  9. from thrift.transport import TTransport
  10. from thrift.protocol import TBinaryProtocol
  11.  
  12. import sasl
  13. import thrift_sasl
  14.  
  15. host = 'localhost'
  16. port = 10200
  17. username = 'saslusername'
  18. password = 'saslusername'
  19. configuration = {}
  20.  
  21. sasl_mech = 'PLAIN'
  22. saslc = sasl.Client()
  23. saslc.setAttr("username", username)
  24. saslc.setAttr("password", password)
  25. saslc.init()
  26.  
  27. socket = TSocket.TSocket(host, port)
  28. transport = thrift_sasl.TSaslClientTransport(saslc, sasl_mech, socket)
  29. protocol = TBinaryProtocol.TBinaryProtocol(transport)
  30. client = TCLIService.Client(protocol)
  31. transport.open()
  32. #ttypes.TOpenSessionReq(username=user, password=password, configuration=configuration)
  33. print "OpenSession"
  34. res=client.OpenSession(ttypes.TOpenSessionReq(username=username, password=password, configuration=configuration))
  35. session = res.sessionHandle
  36. print res
  37.  
  38. print "ExecuteStatement"
  39. res = client.ExecuteStatement(ttypes.TExecuteStatementReq(session, statement='select * from table limit 100', confOverlay={}))
  40. operationHandle = res.operationHandle
  41. print res
  42.  
  43. print "TGetOperationStatusReq"
  44. res = client.GetOperationStatus(ttypes.TGetOperationStatusReq(operationHandle=operationHandle))
  45. print res
  46.  
  47. print "TFetchResultsReq"
  48. res = client.FetchResults(ttypes.TFetchResultsReq(operationHandle=operationHandle, orientation=0, maxRows=100000))
  49. print res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement