Skip to main content

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_മ്മ)

Metadata

Release files for aquilapy 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aquilapy 0.3.1
File Size Uploaded
aquilapy-0.3.1.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aquilapy 0.3.1
File Interpreter ABI Platform
aquilapy-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.4 kB

Release files / aquilapy-0.3.1.tar.gz

Download URL aquilapy-0.3.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9703574063ffc4cd3ab146c75843391794048fe0c8f630f37daeca1407d60fce
BLAKE2b-256 checksum
How to use checksums
7e92c3f112290df46c9daedccbbf5f3d6eb524e0ced376575784ab6b1cc7b0d0
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / aquilapy-0.3.1-py3-none-any.whl

Download URL aquilapy-0.3.1-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b94c2411a97601f2f6848313cbcf2cb64705e93c8c25385c464cd84c6c230a8
BLAKE2b-256 checksum
How to use checksums
ff4fb49e6518737e3138af10cbc9b2fe36de07a191f1f3958aefb48337bb7881
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page