A Cottontail DB gRPC client.
Project description
Cottontail DB gRPC Python Client
A Cottontail DB gRPC client for Python. Built with Cottontail DB Proto
version 0.14.0
. Comes with an interactive CLI for remote DB access.
Installation
Clone and install locally, or with pip install cottontaildb-client
.
Usage
Running the interactive CLI is as easy as cottontaildb-client [--port PORT] host
.
Example usage in scripts:
from cottontaildb_client import CottontailDBClient, Type, Literal, column_def
with CottontailDBClient('localhost', 1865) as client:
# Create schema
client.create_schema('example_schema')
# Define entity columns
columns = [
column_def('id', Type.STRING, nullable=False),
column_def('value', Type.INTEGER, nullable=True)
]
# Create entity
client.create_entity('example_schema', 'example_entity', columns)
# Insert entry
entry = {'id': Literal(stringData='test_1'), 'value': Literal(intData=1)}
client.insert('example_schema', 'example_entity', entry)
# Insert batch
columns = ['id', 'value']
values = [
[Literal(stringData='test_10'), Literal(intData=10)],
[Literal(stringData='test_20'), Literal(intData=20)],
[Literal(stringData='test_null'), Literal()]
]
client.insert_batch('example_schema', 'example_entity', columns, values)
Developing
To update the gRPC client, regenerate cottontaildb_pb2.py
and cottontaildb_pb2_grpc.py
from the proto definitions
file in the Cottontail DB Proto repository.
The following is an approximate guide on how to do so from a terminal:
# Get the latest version of the Cottontail DB proto
wget https://github.com/vitrivr/cottontaildb-proto/raw/master/src/main/protobuf/cottontail.proto
# Install necessary python packages
pip install grpcio grpcio-tools
# Generate the gRPC client
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. cottontail.proto
# Update the client files (where PYTHON_CLIENT_PATH is the path to this repository)
mv cottontail_pb2.py cottontail_pb2_grpc.py $PYTHON_CLIENT_PATH/cottontaildb_client/
Finally, the line import cottontail_pb2 as cottontail__pb2
in the file cottontail_pb2_grpc.py
must be replaced
with from . import cottontail_pb2 as cottontail__pb2
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for cottontaildb-client-0.0.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e10088c0e464d8437e93751f7612c0d7e5fd96f431167f4cee4443622f97aa6b |
|
MD5 | e050344ad2364339d64fbf5a521f2585 |
|
BLAKE2b-256 | 134941653e35865d41c1b47b24d5c98b46b0ed083a81e636d8d40d4be6a750b3 |
Hashes for cottontaildb_client-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 118dad415095f1cd333ef79580ae5db0324065882bd4f70b1d0d5ace5d8b6f7f |
|
MD5 | 64441e65694ce2c41fd6d234f1596c67 |
|
BLAKE2b-256 | f03f5359e178e977f36a922276774a80be181c351335605b7038f9470f7d77a2 |