Skip to main content

dingodb is dingodb sdk

Project description

python-dingodb

The DingoDB python sdk

First, you have prepared the DingoDB environment, see the docs at https://github.com/dingodb/dingo-deploy.git

For more information about DingoDB, see the docs at https://dingodb.readthedocs.io/en/latest/

How to Contribute

1. Compile

pip install -r requirements.txt
git submodule update --init --recursive

2. Release

Usage

Installation

  1. Install from pypi
pip3 install dingodb
  1. Install from Source
pip install git+https://github.com/dingodb/pydingo.git

Basic API

Creating an index

The following example creates an index without a metadata configuration.

>>> import dingodb
>>> dingo_client = dingodb.DingoDB("user", "password", ["172.20.3.20:13000"])
>>> dingo_client.create_index("testdingo", 6, index_type="flat")
True

dingodb provides flexible indexing parameters.

>>> help(dingo_client.create_index)
create_index(index_name, dimension, index_type='hnsw', metric_type='euclidean', replicas=3, index_config=None, metadata_config=None, partition_rule=None, auto_id=True)

Get index

The following example returns all indexes in your schema.

>>> dingo_client.get_index()
['testdingo']

Get index info

The following example returns the info in specified index.

>>> dingo_client.describe_index_info("testdingo")
{'name': 'testdingo', 'version': 0, 'replica': 3, 'autoIncrement': 1, 'indexParameter': {'indexType': 'INDEX_TYPE_VECTOR', 'vectorIndexParameter': {'vectorIndexType': 'VECTOR_INDEX_TYPE_FLAT', 'flatParam': {'dimension': 6, 'metricType': 'METRIC_TYPE_L2'}, 'ivfFlatParam': None, 'ivfPqParam': None, 'hnswParam': None, 'diskAnnParam': None}}}

Add vector

The following example add vector to database.

>>> dingo_client.vector_add("testdingo", [{"a1":"b1", "aa1":"bb1"}, {"a1": "b1"}],[[0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926], [0.27746424078941345,0.801872193813324,0.9581393599510193,0.8759326338768005,0.35781726241111755,0.5009950995445251]])
[{'id': 1, 'vector': {'dimension': 6, 'valueType': 'FLOAT', 'floatValues': [0.19151945, 0.62210876, 0.43772775, 0.7853586, 0.77997583, 0.2725926], 'binaryValues': []}, 'scalarData': {'a1': {'fieldType': 'STRING', 'fields': [{'data': 'b1'}]}, 'aa1': {'fieldType': 'STRING', 'fields': [{'data': 'bb1'}]}}}, {'id': 2, 'vector': {'dimension': 6, 'valueType': 'FLOAT', 'floatValues': [0.27746424, 0.8018722, 0.95813936, 0.87593263, 0.35781726, 0.5009951], 'binaryValues': []}, 'scalarData': {'a1': {'fieldType': 'STRING', 'fields': [{'data': 'b1'}]}}}]

Get MAX ID

you can use autoIncrement id, The following example get max id

>>> dingo_client.get_max_index_row("testdingo")
2

Search Vector

The following example Basic Search without metata.

>>> dingo_client.vector_search("testdingo", [[0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926]], 10)
[{'vectorWithDistances': [{'id': 1, 'vector': {'dimension': 6, 'valueType': 'FLOAT', 'floatValues': [], 'binaryValues': []}, 'scalarData': {'a1': {'fieldType': 'STRING', 'fields': [{'data': 'b1'}]}, 'aa1': {'fieldType': 'STRING', 'fields': [{'data': 'bb1'}]}}, 'distance': 0.0}, {'id': 2, 'vector': {'dimension': 6, 'valueType': 'FLOAT', 'floatValues': [], 'binaryValues': []}, 'scalarData': {'a1': {'fieldType': 'STRING', 'fields': [{'data': 'b1'}]}}, 'distance': 0.5491189}]}]

The following example Search with metata.

>>> dingo_client.vector_search("testdingo", [0.19151945,0.62210876,0.43772775,0.7853586,0.77997583,0.2725926],10, {"meta_expr": {"aa1": "bb1"}})
{'vectorWithDistances': [{'id': 1, 'vector': {'dimension': 6, 'valueType': 'FLOAT', 'floatValues': [], 'binaryValues': []}, 'scalarData': {'aa1': {'fieldType': 'STRING', 'fields': [{'data': 'bb1'}]}, 'a1': {'fieldType': 'STRING', 'fields': [{'data': 'b1'}]}}, 'distance': 0.0}]}

Query vector with ids

The following example Query vector with ids.

>>> dingo_client.vector_get("testdingo", [2])
[{'id': 2, 'vector': {'dimension': 6, 'valueType': 'FLOAT', 'floatValues': [0.27746424, 0.8018722, 0.95813936, 0.87593263, 0.35781726, 0.5009951], 'binaryValues': []}, 'scalarData': {'a1': {'fieldType': 'STRING', 'fields': [{'data': 'b1'}]}}}]

Detele vector with ids

The following example Detele vector with ids.

>>> dingo_client.vector_delete("testdingo", [2])
[True]

Drop index

The following example Drop one index.

>>> dingo_client.delete_index("testdingo")
True

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

dingodb-0.0.17rc15.tar.gz (55.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dingodb-0.0.17rc15-py3-none-any.whl (64.4 kB view details)

Uploaded Python 3

File details

Details for the file dingodb-0.0.17rc15.tar.gz.

File metadata

  • Download URL: dingodb-0.0.17rc15.tar.gz
  • Upload date:
  • Size: 55.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for dingodb-0.0.17rc15.tar.gz
Algorithm Hash digest
SHA256 da3a06e9989360e867d78b5dc48f2b36abe7b5e56b4dbd5a3bd132b8b06e5412
MD5 d5fb69094fe59d04574d5b940f27d0b9
BLAKE2b-256 0db1a3bb2289de95fb1f8024c4b77830bfbc8ab76f20d9e9fb935704313af518

See more details on using hashes here.

File details

Details for the file dingodb-0.0.17rc15-py3-none-any.whl.

File metadata

  • Download URL: dingodb-0.0.17rc15-py3-none-any.whl
  • Upload date:
  • Size: 64.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.2

File hashes

Hashes for dingodb-0.0.17rc15-py3-none-any.whl
Algorithm Hash digest
SHA256 40662c1bd613532e3371ff83b6d5b1e8fa52b269a31d244601cb7cde3a566c95
MD5 3c263a1a860d27022f4ac1fd5232c7e3
BLAKE2b-256 53cfb89ffbf915255287f919adf974b81a1f032cfe475df7a392338090b7fac2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page