Connecting to Db2¶
Anaconda Enterprise enables you to connect to an IBM Db2 relational database management system (RDMS), to access the data stored in it without leaving the platform.
Before you can do so, you’ll need to build the ibm_db
package, which contains the driver required to connect to Db2:
Run the following command to generate a boilerplate or skeleton recipe, which you can then edit:
Locate the
meta.yaml
file within theibm_db
directory that’s created.To build the package for a specific Python version, edit the
meta.yaml
file and specify the version. For example, to build the package for Python 3.6, it would look like this:
Run the following command to build the package:
When complete, the output of the process will display the path to the package. Now you can upload it to your preferred channel, to make it available for platform users. See Uploading a conda package for more information.
To install the package, use the following command:
NOTE: Any packages you install from the command line are available during the current session only. If you want them to persist, add them to the project’s anaconda-project.yml
file. For more information, see Developing a project.
Then you can use code such as this to connect to the Db2 database from within a notebook session:
See Storing secrets for information about adding credentials to the platform, to make them available in your projects. Any secrets you add will be available across all sessions and deployments associated with your user account.