Skip to main content

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
import numpy as np

# Create a wallet instance from private key
wallet = Wallet("<path to>/openssl/private_unencrypted.pem")

# Connect to a running AquilaDB instance
db = DB("http://127.0.0.1", "5000", wallet)

# Schema definition to be used
schema_def = {
    "description": "this is my database",
    "unique": "r8and0mseEd901",
    "encoder": "example.com/autoencoder/API",
    "codelen": 3,
    "metadata": {
        "name": "string",
        "age": "number"
    }
}

# Craete a database with the schema definition provided
db_name = db.create_database(schema_def)

# Prepare documents to be inserted
docs = [{
    "metadata": {
        "name":"name1", 
        "age": 20
    },
    "code": [1,2,3]
}, {
        "metadata": {
        "name":"name2", 
        "age": 30
    },
    "code": [1,2,3]
}]

# 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, 784).tolist()

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


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.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

aquilapy-0.3-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

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