# queuery_client_python
Queuery Redshift HTTP API Client for Python
## Installation
`pip install queuery-client`
## Usage
### Prerequisites
Set the following envronment variables to connect Queuery server:
- `QUEUERY_TOKEN`: Specify Queuery access token
- `QUEUERY_TOKEN_SECRET`: Specify Queuery secret access token
- `QUEUERY_ENDPOINT`: Specify a Queuery endpoint URL via environment variables if you don't set the `endpoint` argument of `QueueryClient` in you code
### Basic Usage
```python
from queuery_client import QueueryClient
client = QueueryClient(endpoint="https://queuery.example.com")
response = client.run("select column_a, column_b from the_great_table")
# (a) iterate `response` naively
for elems in response:
print(response)
# (b) invoke `read()` to fetch all records
print(response.read())
# (c) invoke `read()` with `use_pandas=True` (returns `pandas.DataFrame`)
print(response.read(use_pandas=True))
```
### Type Cast
By default, `QueueryClient` returns all values as `str` regardless of their definitions on Redshift.
You can use the `enable_cast` option to automatically convert types of the returned values into appropreate ones based on their definitions.
```python
from queuery_client import QueueryClient
client = QueueryClient(
endpoint="https://queuery.example.com",
enable_cast=True, # Cast types of the returned values automatically!
)
sql = "select 1, 1.0, 'hoge', true, date '2021-01-01', timestamp '2021-01-01', null"
response = client.run(sql)
response.read() # => [[1, 1.0, 'hoge', True, datetime.date(2021, 1, 1), datetime.datetime(2021, 1, 1, 0, 0), None]]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/bricolages/queuery_client_python",
"name": "queuery-client",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "altescy",
"author_email": "yasuhiro-yamaguchi@cookpad.com",
"download_url": "https://files.pythonhosted.org/packages/49/b9/b497e150d582bbd3a4a1774911607da0cc14fc1f952522ff6809a837b282/queuery_client-1.1.1.tar.gz",
"platform": null,
"description": "# queuery_client_python\n\nQueuery Redshift HTTP API Client for Python\n\n## Installation\n\n`pip install queuery-client`\n\n## Usage\n\n### Prerequisites\n\nSet the following envronment variables to connect Queuery server:\n\n- `QUEUERY_TOKEN`: Specify Queuery access token\n- `QUEUERY_TOKEN_SECRET`: Specify Queuery secret access token\n- `QUEUERY_ENDPOINT`: Specify a Queuery endpoint URL via environment variables if you don't set the `endpoint` argument of `QueueryClient` in you code\n\n### Basic Usage\n\n```python\nfrom queuery_client import QueueryClient\n\nclient = QueueryClient(endpoint=\"https://queuery.example.com\")\nresponse = client.run(\"select column_a, column_b from the_great_table\")\n\n# (a) iterate `response` naively\nfor elems in response:\n print(response)\n\n# (b) invoke `read()` to fetch all records\nprint(response.read())\n\n# (c) invoke `read()` with `use_pandas=True` (returns `pandas.DataFrame`)\nprint(response.read(use_pandas=True))\n```\n\n### Type Cast\n\nBy default, `QueueryClient` returns all values as `str` regardless of their definitions on Redshift.\nYou can use the `enable_cast` option to automatically convert types of the returned values into appropreate ones based on their definitions.\n\n```python\nfrom queuery_client import QueueryClient\n\nclient = QueueryClient(\n endpoint=\"https://queuery.example.com\",\n enable_cast=True, # Cast types of the returned values automatically!\n)\n\nsql = \"select 1, 1.0, 'hoge', true, date '2021-01-01', timestamp '2021-01-01', null\"\nresponse = client.run(sql)\nresponse.read() # => [[1, 1.0, 'hoge', True, datetime.date(2021, 1, 1), datetime.datetime(2021, 1, 1, 0, 0), None]]\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Queuery Redshift HTTP API Client for Python",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/bricolages/queuery_client_python"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4a7f1a7642ff991ea74891ca7e96818d5c78d97ba60bfd4bc90f27dd9bf67be2",
"md5": "a124ede5060ded5f670dcee873cc8929",
"sha256": "b1b22be83e6636b8e99d0ae484fdd68b41f5a612063864766dd1ae186b2d2734"
},
"downloads": -1,
"filename": "queuery_client-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a124ede5060ded5f670dcee873cc8929",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 8141,
"upload_time": "2024-11-26T06:58:32",
"upload_time_iso_8601": "2024-11-26T06:58:32.419203Z",
"url": "https://files.pythonhosted.org/packages/4a/7f/1a7642ff991ea74891ca7e96818d5c78d97ba60bfd4bc90f27dd9bf67be2/queuery_client-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "49b9b497e150d582bbd3a4a1774911607da0cc14fc1f952522ff6809a837b282",
"md5": "6cd23fc98e2a48aaa7bc789987bec039",
"sha256": "df5aaeee163b7959a57f7c1e81c2da2dff16cce4fe911313f01ecf32494aba21"
},
"downloads": -1,
"filename": "queuery_client-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "6cd23fc98e2a48aaa7bc789987bec039",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 6894,
"upload_time": "2024-11-26T06:58:34",
"upload_time_iso_8601": "2024-11-26T06:58:34.004324Z",
"url": "https://files.pythonhosted.org/packages/49/b9/b497e150d582bbd3a4a1774911607da0cc14fc1f952522ff6809a837b282/queuery_client-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 06:58:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bricolages",
"github_project": "queuery_client_python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "queuery-client"
}