Establishing a Connection
The objects available within our connector are accessible from the "cdata.db2" module. To use the module's objects directly:
- Import the module as follows:
import cdata.db2 as mod
- To establish a connection string, call the connect() method from the connector object using an appropriate connection string, such as:
mod.connect("Server=10.0.1.2;Port=50000;User=admin;Password=admin;Database=test")
Connecting to DB2
Set the following properties to connect:- Server: The name of the server running DB2.
- Port: The port the DB2 server is listening on.
- Database: The name of the DB2 database.
Authenticating to DB2
The connector supports authenticating directly to the DB2 with user credentials as well as authenticating using the API key of an application integrated with DB2, such as Watson Query.
DB2 User Credentials
Set AuthScheme to USRIDPWD. Provide the following credentials:
- User: The username of a user with access to the database.
- Password: The password of a user with access to the database.
IAM
The connector supports authenticating to the DB2 server using the API key of an application that connects to it, such as Watson Query.
Set AuthScheme to IBMIAMAuth. Provide the following credentials:
- User: The IBMid or service ID tied to a user of the DB2 server.
- Password: The API key associated with the application that requires access to the DB2 database.