Python client library for Aquila Network
Project description
AquilaDB-Python
Python client library for Aquila Network
install
pip install aquilapy
Tutorial
from aquilapy import Wallet, DB, Hub
import numpy as np
import time
# Create a wallet instance from private key
wallet = Wallet("private_unencrypted.pem")
host = "http://127.0.0.1"
# Connect to Aquila DB instance
db = DB(host, "5001", wallet)
# Connect to Aquila Hub instance
hub = Hub(host, "5002", wallet)
# Schema definition to be used
schema_def = {
"description": "this is my database",
"unique": "r8and0mseEd901",
"encoder": "ftxt:https://ftxt-models.s3.us-east-2.amazonaws.com/ftxt_base_min.bin",
"codelen": 25,
"metadata": {
"name": "string",
"age": "number"
}
}
# Craete a database with the schema definition provided
db_name = db.create_database(schema_def)
# Craete a database with the schema definition provided
db_name_ = hub.create_database(schema_def)
print(db_name, db_name_)
# Generate encodings
texts = ["Amazon", "Google"]
compression = hub.compress_documents(db_name, texts)
print(compression)
# Prepare documents to be inserted
docs = [{
"metadata": {
"name":"name1",
"age": 20
},
"code": compression[0]
}, {
"metadata": {
"name":"name2",
"age": 30
},
"code": compression[1]
}]
# Insert documents
dids = db.insert_documents(db_name, docs)
print(dids)
# Delete some documents
dids = db.delete_documents(db_name, dids)
print(dids)
# Perform a similarity search operation
matrix = np.random.rand(1, 25).tolist()
time.sleep(5)
docs, dists = db.search_k_documents(db_name, matrix, 10)
print(len(docs[0]), len(dists[0]))
created with ❤️ a-mma.indic (a_മ്മ)
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
aquilapy-0.3.1.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file aquilapy-0.3.1.tar.gz
.
File metadata
- Download URL: aquilapy-0.3.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9703574063ffc4cd3ab146c75843391794048fe0c8f630f37daeca1407d60fce |
|
MD5 | e7324e5ef6752f47557aaf92f922dc41 |
|
BLAKE2b-256 | 7e92c3f112290df46c9daedccbbf5f3d6eb524e0ced376575784ab6b1cc7b0d0 |
File details
Details for the file aquilapy-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: aquilapy-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b94c2411a97601f2f6848313cbcf2cb64705e93c8c25385c464cd84c6c230a8 |
|
MD5 | 9dc4bf6c161fd0c32daf55a399fd2293 |
|
BLAKE2b-256 | ff4fb49e6518737e3138af10cbc9b2fe36de07a191f1f3958aefb48337bb7881 |