Queuery Redshift HTTP API Client for Python
Project description
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 tokenQUEUERY_TOKEN_SECRET
: Specify Queuery secret access tokenQUEUERY_ENDPOINT
: Specify a Queuery endpoint URL via environment variables if you don't set theendpoint
argument ofQueueryClient
in you code
Basic Usage
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.
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]]
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
queuery_client-1.1.0.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for queuery_client-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c3639e8c2d5c61e9bbd42ed1afa8d884fa47780d226b4a60e591badfa593b9e |
|
MD5 | 5213782ba642c9a6e5dd25be8ca9758a |
|
BLAKE2b-256 | 2996b8e0e89cb799ebff16af9b5fcddcc55eefbed6c3a8d260a0aff9a5f0c7a7 |