Skip to main content

Python DB-API driver for Wherobots DB

Project description

wherobots-python-dbapi-driver

Python DB-API implementation for Wherobots DB. This package implements a PEP-0249 compatible driver to programmatically connect to a Wherobots DB runtime and execute Spatial SQL queries.

Installation

If you use Poetry in your project, add the dependency with poetry add:

$ poetry add git+https://github.com/wherobots/wherobots-python-dbapi-driver

Otherwise, just pip install it:

$ pip install git+https://github.com/wherobots/wherobots-python-dbapi-driver

Usage

Basic usage

Basic usage follows the typical pattern of establishing the connection, acquiring a cursor, and executing SQL queries through it:

from wherobots.db import connect
from wherobots.db.region import Region
from wherobots.db.runtime import Runtime

with connect(
        api_key='...',
        runtime=Runtime.SEDONA,
        region=Region.AWS_US_WEST_2) as conn:
    curr = conn.cursor()
    curr.execute("SHOW SCHEMAS IN wherobots_open_data")
    results = curr.fetchall()
    print(results)

The Cursor supports the context manager protocol, so you can use it within a with statement when needed:

with connect(...) as conn:
    with conn.cursor() as curr:
        curr.execute(...)
        results = curr.fetchall()

It also implements the close() method, as suggested by the PEP-2049 specification, to support situations where the cursor is wrapped in a contextmanager.closing().

Runtime and region selection

You can chose the Wherobots runtime you want to use using the runtime parameter, passing in one of the Runtime enum values. For more information on runtime sizing and selection, please consult the Wherobots product documentation.

The only supported Wherobots compute region for now is aws-us-west-2, in AWS's Oregon (us-west-2) region.

Advanced parameters

The connect() method takes some additional parameters that advanced users may find useful:

  • results_format: one of the ResultsFormat enum values; Arrow encoding is the default and most efficient format for receiving query results.
  • data_compression: one of the DataCompression enum values; Brotli compression is the default and the most efficient compression algorithm for receiving query results.
  • geometry_representation: one of the GeometryRepresentation enum values; selects the encoding of geometry columns returned to the client application. The default is EWKT (string) and the most convenient for human inspection while still being usable by libraries like Shapely.

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

wherobots_python_dbapi-0.5.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

wherobots_python_dbapi-0.5.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file wherobots_python_dbapi-0.5.1.tar.gz.

File metadata

File hashes

Hashes for wherobots_python_dbapi-0.5.1.tar.gz
Algorithm Hash digest
SHA256 a9401d515ff50ebac475d5b6607f49ccf35efa2dba804613f4b50199256ffbf0
MD5 b2ed9b0fb457d614af1c8a661b855651
BLAKE2b-256 39f77b850818c611d6c9fefb7fc6f002526b9dd313acafd34eb0399c960c6f11

See more details on using hashes here.

File details

Details for the file wherobots_python_dbapi-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for wherobots_python_dbapi-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d59d8e87370f29ad9b6cccdfedd254a92841d20e200553b134c0416dd089b1f
MD5 ca2e39ded1e0f1fc330433bf90338c26
BLAKE2b-256 46e7b1b6ec6b082bc7dff61a50e1bf70d80d2cd263950d4d42f801531ebd44d9

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