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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e361001c61e35036a7c5aab6b2b95a59dfcd2ea8ee937b2f766b6cfea7ee2b1 |
|
MD5 | d4ee43b7222ba6e0a5f8ab636a13747c |
|
BLAKE2b-256 | 17aee50dbe034e0d23ded0eced444fd30d648ee6abb1b68f1c8da20887cb6705 |
Hashes for cottontaildb_client-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b20941a67d6ec3e3ce7e5e7ca3abcab98c5c311ed4399f3ef3a2984c2c04d054 |
|
MD5 | b5af359cd2c6bd286b8fe99de566df34 |
|
BLAKE2b-256 | f21bcfe0645606f6c8f61163a461c48b338075ee391dd86420fdedb5ca83b373 |