Path: blob/main/DataVirtualization-L3-Tech-Lab/wq_lab_notebook.ipynb
1928 views
Watson Query Data Virtualization Lab Notebook
This notebook is intended to be used with the IBM Watson Query Level 3 for Technical Sales lab (link).
Perform the work in each section as instructed in the main lab guide.
Section #1: Connect to Watson Query
Run the following cell to install the ibm_db driver package. This provides a Python interface for connecting to IBM Db2 (for Linux, UNIX, and Windows), IBM Db2 for z/OS, IBM Informix, and IBM Db2-based offerings and services, like Watson Query.
Run the following cell to import the libraries used by this notebook.
Run the following two cells to download and load Db2 Jupyter Notebook extensions (Db2 magic commands).
Note: For more information on these Db2 Jupyter Notebook extensions, please see the following resources:
Update the environment settings (
hostname,portnum, andapikey) in the following cell based on your own Watson Query environment and then run the cell. Instructions on where to get these values are provided in the main lab guide.
Update the following cell with your Watson Query user ID (specify it in all UPPERCASE letters). This user ID is also used as the schema name for any virtual objects you create in Watson Query and that is how it is being used here. Instructions on how to find your user ID (schema name) are provided in the main lab guide. After updating the value, run the cell.
Note: This user ID isn't needed for the connection, but it's being set here just to keep all of your settings localized in this one area of the notebook.
After modifying the variables in the previous two cells, persist the changes to the notebook by clicking File > Save from the menu bar at the top of the page.
Run the following cell to connect to Watson Query.
Run the following cell to create a function that will be used to execute SQL query statements against Watson Query.
Run the following cell to perform a simple test query to validate that the connection was successful.
Section #2: Query Virtual Objects
This section assumes that you successfully connected to Watson Query in Section #1 above.
Run the following cell to query the CUSTOMER virtual table (whose data resides in a Db2 Warehouse database). Because you are querying this data as the business user, you can see that the credit card-related data has been masked.
Run the following cell to query the CUSTOMER_LOYALTY table (whose data resides in a PostgreSQL database).
Run the following cell to query the CUSTOMER_LOYALTY_HISTORY table (whose data resides on AWS S3 object storage).
Run the following cell to query the CUSTOMER_SUMMARY_V virtual view (the view created through the graphical interface). This is retrieving and joining data from the two base data sources. Once again, see how the credit card data is masked! The business user isn't seeing data that they don't have the authority to see.
Run the following cell to query the CUSTOMER_SUMMARY_V2 virtual view (the view created by executing a SQL statement).
Section #3: Data Caches - Running Workload to Generate Query History
This section assumes that you successfully connected to Watson Query in Section #1 above.
Run the following two cells to issue queries against the virtual objects. Query execution will take approximately 10-15 minutes.
This concludes the notebook portion of the lab.