如何使用命令行界面从 gpudb(kinetica) 表中获取记录

How to fetch records from gpudb(kinetica) tables using command line interface

我正在尝试连接到 gpudb 表,但遇到异常。

我用来连接到 gpudb 表的命令是:

python gpudb_cmd.py --gpudb < ip >:< port > --username < username > --ask-password  --query 'select * from collectionname.tablename'

异常:

<p>Traceback (most recent call last): <br>
  File "gpudb_cmd.py", line 248, in <module> <br>
     gpudb_cmd( sys.argv ) <br>
  File "gpudb_cmd.py", line 81, in gpudb_cmd <br>
    gpudb = GPUdb( encoding = encoding, host = GPUdb_IP, port = GPUdb_Port, <br>username = args.username, password = password ) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/gpudb.py", <br>line 1531, in __init__ <br>
    server_status_response = self.show_system_status() <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/gpudb.py", <br>line 9585, in show_system_status <br>
    return AttrDict( self.__post_then_get( REQ_SCHEMA, REP_SCHEMA, obj, '/show/system/status' ) ) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/gpudb.py",<br> line 1840, in __post_then_get <br>
    return self.__read_datum(REP_SCHEMA, response, None, response_time) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/gpudb.py", <br>line 1777, in __read_datum <br>
    resp = self.__read_orig_datum(REP_SCHEMA, encoded_datum, encoding) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/gpudb.py",  <br>line 1756, in __read_orig_datum <br>
    return _Util.decode_binary_data( SCHEMA, encoded_datum ) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/gpudb.py", <br>line 280, in decode_binary_data <br>
    out = reader.read( bd ) # read, give a decoder <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/packages <br>/avro/avro_py2/io.py", line 451, in read <br>
    return self.read_data(self.writers_schema, self.readers_schema, decoder) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/packages <br>/avro/avro_py2/io.py", line 496, in read_data <br>
    return self.read_record(writers_schema, readers_schema, decoder) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/packages <br>/avro/avro_py2/io.py", line 696, in read_record <br>
    field_val = self.read_data(field.type, readers_field.type, decoder) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/packages <br>/avro/avro_py2/io.py", line 484, in read_data <br>
    return decoder.read_bytes() <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/packages <br>/avro/avro_py2/io.py", line 232, in read_bytes <br>
    return self.read(self.read_long()) <br>
  File "/home/test/GIT/kinetica-api/kinetica-api-python/gpudb/packages <br>/avro/avro_py2/io.py", line 190, in read_long <br> 
    b = ord(self.read(1)) <br>
TypeError: ord() expected a character, but string of length 0 found" <br>
 </p>

这可以使用以下代码解决:

import gpudb
db = gpudb.GPUdb(encoding = 'BINARY', host = <host_ip>, port = <dbport>)
options = {}

response = db.aggregate_statistics(<tableName>, "columnname", stats="count")
return int(response["stats"]["count"])