Name | wherobots-python-dbapi JSON |
Version |
0.9.1
JSON |
| download |
home_page | None |
Summary | Python DB-API driver for Wherobots DB |
upload_time | 2024-11-08 04:36:46 |
maintainer | None |
docs_url | None |
author | Maxime Petazzoni |
requires_python | <4.0,>=3.9 |
license | Apache 2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# wherobots-python-dbapi
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](https://python-poetry.org) in your project, add the
dependency with `poetry add`:
```
$ poetry add wherobots-python-dbapi
```
Otherwise, just `pip install` it:
```
$ pip install wherobots-python-dbapi
```
## Usage
### Basic usage
Basic usage follows the typical pattern of establishing the connection,
acquiring a cursor, and executing SQL queries through it:
```python
from wherobots.db import connect
from wherobots.db.region import Region
from wherobots.db.runtime import Runtime
with connect(
api_key='...',
runtime=Runtime.TINY,
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:
```python
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](https://docs.wherobots.com).
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.
* `reuse_session`: controls whether an existing runtime of the same type
and in the same region that is available should be re-used for this
connection. This is the default behavior.
Raw data
{
"_id": null,
"home_page": null,
"name": "wherobots-python-dbapi",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Maxime Petazzoni",
"author_email": "max@wherobots.com",
"download_url": "https://files.pythonhosted.org/packages/db/18/dbc4b4aa2a7176b7fa5631e7080537982edc0a7605d8d90b15a47c6daee5/wherobots_python_dbapi-0.9.1.tar.gz",
"platform": null,
"description": "# wherobots-python-dbapi\n\nPython DB-API implementation for Wherobots DB. This package implements a\nPEP-0249 compatible driver to programmatically connect to a Wherobots DB\nruntime and execute Spatial SQL queries.\n\n## Installation\n\nIf you use [Poetry](https://python-poetry.org) in your project, add the\ndependency with `poetry add`:\n\n```\n$ poetry add wherobots-python-dbapi\n```\n\nOtherwise, just `pip install` it:\n\n```\n$ pip install wherobots-python-dbapi\n```\n\n## Usage\n\n### Basic usage\n\nBasic usage follows the typical pattern of establishing the connection,\nacquiring a cursor, and executing SQL queries through it:\n\n```python\nfrom wherobots.db import connect\nfrom wherobots.db.region import Region\nfrom wherobots.db.runtime import Runtime\n\nwith connect(\n api_key='...',\n runtime=Runtime.TINY,\n region=Region.AWS_US_WEST_2) as conn:\n curr = conn.cursor()\n curr.execute(\"SHOW SCHEMAS IN wherobots_open_data\")\n results = curr.fetchall()\n print(results)\n```\n\nThe `Cursor` supports the context manager protocol, so you can use it\nwithin a `with` statement when needed:\n\n```python\nwith connect(...) as conn:\n with conn.cursor() as curr:\n curr.execute(...)\n results = curr.fetchall()\n```\n\nIt also implements the `close()` method, as suggested by the PEP-2049\nspecification, to support situations where the cursor is wrapped in a\n`contextmanager.closing()`.\n\n### Runtime and region selection\n\nYou can chose the Wherobots runtime you want to use using the `runtime`\nparameter, passing in one of the `Runtime` enum values. For more\ninformation on runtime sizing and selection, please consult the\n[Wherobots product documentation](https://docs.wherobots.com).\n\nThe only supported Wherobots compute region for now is `aws-us-west-2`,\nin AWS's Oregon (`us-west-2`) region.\n\n### Advanced parameters\n\nThe `connect()` method takes some additional parameters that advanced\nusers may find useful:\n\n* `results_format`: one of the `ResultsFormat` enum values;\n Arrow encoding is the default and most efficient format for\n receiving query results.\n* `data_compression`: one of the `DataCompression` enum values; Brotli\n compression is the default and the most efficient compression\n algorithm for receiving query results.\n* `geometry_representation`: one of the `GeometryRepresentation` enum\n values; selects the encoding of geometry columns returned to the\n client application. The default is EWKT (string) and the most\n convenient for human inspection while still being usable by\n libraries like Shapely.\n* `reuse_session`: controls whether an existing runtime of the same type\n and in the same region that is available should be re-used for this\n connection. This is the default behavior.\n\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Python DB-API driver for Wherobots DB",
"version": "0.9.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "df23a72dab429b1a3e8e59204e4732877084cb06a7f58994950ab24b06f04c5c",
"md5": "ebe95e0f30fc2bfc09b9f71e65a66993",
"sha256": "addd018793c39e9e3cb06c20bcc47724a81f8926d27e05f330863862ac688699"
},
"downloads": -1,
"filename": "wherobots_python_dbapi-0.9.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ebe95e0f30fc2bfc09b9f71e65a66993",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 15538,
"upload_time": "2024-11-08T04:36:44",
"upload_time_iso_8601": "2024-11-08T04:36:44.337068Z",
"url": "https://files.pythonhosted.org/packages/df/23/a72dab429b1a3e8e59204e4732877084cb06a7f58994950ab24b06f04c5c/wherobots_python_dbapi-0.9.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "db18dbc4b4aa2a7176b7fa5631e7080537982edc0a7605d8d90b15a47c6daee5",
"md5": "84563d51c2c9a02e080d44603661318d",
"sha256": "7e829cdd009593414d1635fcfb83b5a373ec7c66879a235c1633b7e234ef6159"
},
"downloads": -1,
"filename": "wherobots_python_dbapi-0.9.1.tar.gz",
"has_sig": false,
"md5_digest": "84563d51c2c9a02e080d44603661318d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 13929,
"upload_time": "2024-11-08T04:36:46",
"upload_time_iso_8601": "2024-11-08T04:36:46.576055Z",
"url": "https://files.pythonhosted.org/packages/db/18/dbc4b4aa2a7176b7fa5631e7080537982edc0a7605d8d90b15a47c6daee5/wherobots_python_dbapi-0.9.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-08 04:36:46",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "wherobots-python-dbapi"
}