Note
| Ensure that the API is available in your workspace environment; see Install the Data API for setup information. |
The Datasource client uses environment variables available in the workspace to automatically authenticate your identity.
To override this behavior, see Custom Authentication.
Assuming a data source named redshift-test
is configured with valid credentials for the current user:
from domino.data_sources import DataSourceClient
# instantiate a client and fetch the datasource instance
redshift = DataSourceClient().get_datasource("redshift-test")
query = """
SELECT
firstname,
lastname,
age
FROM
employees
LIMIT 1000
"""
# res is a simple wrapper of the query result
res = redshift.query(query)
# to_pandas() loads the result into a pandas dataframe
df = res.to_pandas()
# check the first 10 rows
df.head(10)
library(DominoDataR)
client <- DominoDataR::datasource_client()
query <- "
SELECT
firstname,
lastname,
age
FROM
employees
LIMIT 1000"
# table is a https://arrow.apache.org/docs/r/reference/Table-class.html
table <- DominoDataR::query(client, "redshift-test", query)
#> Table
#> 1000 rows x 3 columns
#> $firstname <string not null>
#> $lastname <string not null>
#> $age <int32 not null>