Ejemplo n.º 1
0
def import_some_rows(session, table_name, client):
  input_rows = []
  for i in xrange(0, 100):
    input_row = MapD.TStringRow()
    input_row.cols = [
      MapD.TStringValue(str(i)),
      MapD.TStringValue('str%d' % i),
      MapD.TStringValue('real_str%d' % i)
    ]
    input_rows.append(input_row)
  client.load_table(session, table_name, input_rows)
Ejemplo n.º 2
0
 def __init__(self,
              user=None,
              password=None,
              host=None,
              port=9091,
              dbname=None,
              protocol="http"):
     if protocol == "http":
         if not host.startswith(protocol):
             # the THttpClient expects http[s]://localhost
             host = protocol + '://' + host
         transport = THttpClient.THttpClient(host)
         proto = TJSONProtocol.TJSONProtocol(transport)
         socket = None
     elif protocol == "binary":
         socket = TSocket.TSocket(host, port)
         transport = TTransport.TBufferedTransport(socket)
         proto = TBinaryProtocol.TBinaryProtocol(transport)
     else:
         raise TypeError("`protocol` should be one of ['http', 'binary'], ",
                         "got {} instead".format(protocol))
     self._user = user
     self._password = password
     self._host = host
     self._port = port
     self._dbname = dbname
     self._transport = transport
     self._protocol = protocol
     self._socket = socket
     self._transport.open()
     self._client = MapD.Client(proto)
     self._session = self._client.connect(user, password, dbname)
Ejemplo n.º 3
0
def get_client(host, port):
  socket = TSocket.TSocket(host, port)
  transport = TTransport.TBufferedTransport(socket)
  protocol = TBinaryProtocol.TBinaryProtocol(transport)
  client = MapD.Client(protocol)
  transport.open()
  return client
Ejemplo n.º 4
0
def get_client(host_or_uri, port, http):
    if http:
        transport = THttpClient.THttpClient(host_or_uri)
        protocol = TJSONProtocol.TJSONProtocol(transport)
    else:
        socket = TSocket.TSocket(host_or_uri, port)
        transport = TTransport.TBufferedTransport(socket)
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

    client = MapD.Client(protocol)
    transport.open()
    return client