Skip to main content

Python SDK

The Python SDK provides an extensive set of wrappers and utilities that allow you to generate JSON queries for ApertureDB, and process the JSON and binary responses. See ApertureDB Query Language Overview for details of the underlying JSON query language.

Our Python client package can be installed via pip.

pip install --upgrade aperturedb

--upgrade forces an update of the aperturedb package in your current Python environment.

See ApertureDB Python SDK for more information on the SDK. The source code can be found in our repository: aperture-data/aperturedb-python.

Connection to ApertureDB

For more information, see Configuration.

Connection Within Client Code

If you are writing an application in Python, you can connect to the database in the script as follows:

from aperturedb import Connector as Connector
client = Connector(host="<database instance name or IP>", user="admin", password="<YOUR_PASSWORD>")
client.query([{"GetStatus": {}}])

This lets you specify server information per application.

If you want to set a server profile up for any application, you can use the next method.

Connection Profile via Command Line Tool

Our Python SDK comes with a command line utility called adb that's very useful when setting up a client to query the database server. We need to establish a connection profile and validate that the SDK is able to connect to your DB. See Command Line Tool (adb) for more information about using the CLI.

adb config create <config-name>

This command prompts for a few parameters and creates an JSON configuration file in an operating-system-specific location. Here is an example configuation from that file:

{
"host": "localhost", # machine name or IP where database instance is running (default: localhost)]
"port": 55555, # default database port - change for Mac local install
"username": "admin", # created by user (default: admin)
"password": "secret", # user enters password here
"use_ssl": true, # Don't change this unless you kow what you're doing
"use_rest": false, # Don't change this unless you know what you're doing
}

With this method, you can go ahead and create multiple database instance profiles with unique names and switch between them depending on which databse you are working on. See adb command line tool for options and also how to use the various ETL and query parameters.

If there is only one profile, that is activated by default and you should be able to run the following command to verify successful connection:

adb utils execute summary

This command returns the database server version and some other information.

Now, for using in a notebook or Python application, you can simply do:

from aperturedb.CommonLibrary import create_connector
client = create_connector()

To check if you are connected and working, you can use the Utils package:

utils = Utils(client)
print(utils.summary())

To make it easier to use this CLI, you can install completions in the current shell:

adb --install-completion

Deploying Your Own Application

Once ApertureDB server and client are ready, and you are ready to define your application:

  1. You can define your application schema,
  2. Ingest data, and
  3. Start querying and visualizing data.