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 theResultsFormat
enum values; Arrow encoding is the default and most efficient format for receiving query results.data_compression
: one of theDataCompression
enum values; Brotli compression is the default and the most efficient compression algorithm for receiving query results.geometry_representation
: one of theGeometryRepresentation
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file wherobots_python_dbapi-0.6.0.tar.gz
.
File metadata
- Download URL: wherobots_python_dbapi-0.6.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef7f586bd777e85a459d7750f3ad7ec8e90b9816a9d0694408d74e09b8c5148e |
|
MD5 | 54723644f24901593616882dcbc2e284 |
|
BLAKE2b-256 | b525821c2781b5d1ce373f16fc4363e9aa7f8ed6b7517099a4d53e79db9158ed |
File details
Details for the file wherobots_python_dbapi-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: wherobots_python_dbapi-0.6.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf47cb9f2e0cf6d8e09a701499241dcf0e293be52e0a7f7597615a7e665a029f |
|
MD5 | b791638a6c9461f8549114ddf7c5e4bb |
|
BLAKE2b-256 | a9769eba0c58b939de10519a0c2b455760d453b5a2e913c4b7e7f023135d4a05 |