Data sources have a global scope in a Domino deployment and are accessible to anyone with the appropriate permissions in any project.
Use the following steps to connect to a Data Store.
-
From the navigation pane, click Data > Add a Data Source.
-
Enter credentials for the Data Source.
Your admin can set up Data Sources to use either service account credentials or individual user credentials.
-
Click Add to Project.
You can add Data Sources to a project explicitly (Add a data source on project’s Data page) or implicitly when a Data Source is used directly in code from a project.
If a Data Source has been set up and you have permission to access it, you can add it to a project. This step is not strictly necessary, but it gives you visibility into which Data Sources are used in each of your projects.
If you don’t add a Data Source to a project, you can still use it in your code if you have permission to access it.
-
In your project, go to Data > Data Sources > Add a Data Source.
-
Select an existing Data Source from the list.
-
Click Add to Project.
After a Data Source is properly configured, use the Domino Data API to retrieve data without installing drivers or Data Source-specific libraries.
The auto-generated code snippets provided in your workspace are based on the Domino Data API. The API supports tabular and file-based Data Sources and is available for
The Data API comes pre-packaged in the Domino Standard Environment (DSE). If you are using a custom environment that doesn’t have the Data API, you can install it.
The Data API’s Data Source client uses environment variables available in the workspace to automatically authenticate your identity. You can override this behavior using custom authentication.
Get code snippets
Domino automatically generates code snippets for accessing the Data Sources in your project using the Domino Data API. Code snippets are available for Python and R and customized for tabular and file-based Data Sources. The Data Source must be added to your project to enable snippets.
Here’s how to get a code snippet that you can copy and paste in your workspace:
-
In your workspace, go to Data > Data Sources and click the code snippet button:
-
Select Python or R.
-
Copy the code snippet, paste it into your own code, and modify it as needed.
For more auto-generated code, try Domino Code Assist.
Query a tabular store
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)