Skip to main content

Tools for querying an Aircloak service via its postgres api.

Project description

Python Aircloak Tools

A small package for querying an Aircloak service via the postgres api.

The main aim is to provide an Aircloak-friendly wrapper around psycopg2, and in particular to provide clear error messages when something doesn't go as planned.

Query results are return as pandas dataframes.

Example

The following code shows how to initiate a connection and execute a query.

As a pre-requisite you should have a username and password for the postgres interface of an Aircloak installation (ask your admin for these). Assign these values to AIRCLOAK_PG_USER and AIRCLOAK_PG_PASSWORD environment variables.

Note the call to ac.connect() can be used as a context manager: Using the with statement, the connection is automatically closed cleanly when it it goes out of scope.

import aircloak_tools as ac

AIRCLOAK_PG_HOST = "covid-db.aircloak.com"
AIRCLOAK_PG_PORT = 9432

AIRCLOAK_PG_USER = environ.get("AIRCLOAK_PG_USER")
AIRCLOAK_PG_PASSWORD = environ.get("AIRCLOAK_PG_PASSWORD")

TEST_DATASET = "cov_clear"

with ac.connect(host=AIRCLOAK_PG_HOST, port=AIRCLOAK_PG_PORT,
                user=AIRCLOAK_PG_USER, password=AIRCLOAK_PG_PASSWORD, dataset=TEST_DATASET) as conn:

    assert(conn.is_connected())

    tables = conn.get_tables()

    print(tables)

    feeling_now_counts = conn.query('''
    select feeling_now, count(*), count_noise(*)
    from survey
    group by 1
    order by 1 desc
    ''')

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

aircloak-tools-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

aircloak_tools-0.1.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file aircloak-tools-0.1.1.tar.gz.

File metadata

  • Download URL: aircloak-tools-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.6 CPython/3.8.3 Linux/4.19.76-linuxkit

File hashes

Hashes for aircloak-tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9f76939a7e26be002ece2d3c93e19539a4321bdcde6d9ff7b21d70ce12c7faaf
MD5 f0045bd95669b1d795dc85f12cdb0cf6
BLAKE2b-256 232e75bb61f8feca7111203fba9450c057b91bd2f7fa8922ea7206b23950040d

See more details on using hashes here.

File details

Details for the file aircloak_tools-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aircloak_tools-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.6 CPython/3.8.3 Linux/4.19.76-linuxkit

File hashes

Hashes for aircloak_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fe85dfc6f34a766502c913d7c67ee410e5033e1c7ad34818d7434ef178374941
MD5 e8841f0e76ad29afa8a5b072d6b6e7d0
BLAKE2b-256 590c2da8376e1af2a72d9fa27545da0de136ea5dc7b6c45406ad9fd519e50860

See more details on using hashes here.

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