Skip to main content
IBM Db2 is IBM’s relational database, available in IBM Cloud as a managed service. The IBM Db2 connector lets your Lovable app browse the schemas and tables in a Db2 on Cloud instance and run SQL queries against it. IBM Db2 is available as an app + chat connector: one shared connection that works in the project chat while you build and in your published apps. With IBM Db2, your app can:
  • Browse the schemas, tables, and columns the connected database user can see
  • Run SQL queries and show the results in your app
  • Export larger query results as CSV, up to 100,000 rows
Use IBM Db2 when your app needs live data from a Db2 database your team already runs in IBM Cloud.

Common use cases and example apps

These examples show what you can build with IBM Db2, each with a prompt to start from.

How to connect IBM Db2

Who can create IBM Db2 connections depends on your plan and workspace settings. App + chat connectors are available by default on Free, Pro, and Business plans. On Enterprise plans, they are effectively disabled at first: Who can create connections and clients defaults to No one until an admin changes it in Connectors → Admin settings → App + chat connectors. You can create multiple IBM Db2 connections using different instances or database users, which is useful for separating environments or limiting each app to the data its user can see. When the connection is created, you can link it to the projects where you want to use it. Anyone building in a project can ask Lovable in the project chat to link their project to it.

Prerequisites

Before connecting IBM Db2, make sure you have:
  • A Db2 on Cloud instance in your IBM Cloud account
  • A database userid and password for that instance (Step 1 shows where to find them)
  • Permission to create connections in your Lovable workspace (see Who can create connections and clients)
Queries made through this connector run on your Db2 instance and use its compute. Billing is handled directly by IBM Cloud, not Lovable.

Step 1: Get your Db2 endpoint and credentials

The connector signs in with a database userid and password and needs your instance’s REST API endpoint. Queries run with that user’s database privileges. To collect the connection details:
1

Open your instance in IBM Cloud

Sign in to IBM Cloud, open the Resource list, and select your Db2 instance.
2

Create a database credential

Open the instance’s Service credentials tab and click New credential. The credential JSON contains a username and a password for the database. In Step 2, enter the username value in the Userid field.
3

Copy the deployment CRN

The instance panel shows the Cloud Resource Name (CRN), a long identifier starting with crn:v1:bluemix:. Copy it. The connection form asks for it.
4

Note the REST API endpoint

The endpoint is regional: https://<region>.db2.saas.ibm.com, where <region> is the region of your instance, for example us-south.
A service credential has administrator rights. Apps that use it can change or delete data in your database. For most apps, create a read-only database user in the Db2 console (see IBM’s Managing users) and use that user’s userid and password.Keep the password secure. Enter it only in the connection form in Lovable. Do not put it in a prompt, a chat message, or your app’s code.
See IBM’s documentation for more: Database details and connection credentials.

Step 2: Connect IBM Db2 to Lovable

Open the connection form and enter the values from Step 1.
1

Open IBM Db2 in Connectors

Open Connectors and select IBM Db2. For the other places to open the catalog from, see Where to find connectors.
2

Add a connection

Click Add connection and select App + chat connector. The form is split into collapsible sections, Details, Configure connection, and Sharing.
3

Name the connection

Under Details, Lovable fills in a name for the connection, which you can change. The name is only used inside Lovable to identify the connection.
4

Configure the connection

Under Configure connection, enter:
  1. REST API endpoint: the https endpoint from Step 1, for example https://us-south.db2.saas.ibm.com.
  2. Deployment CRN: the CRN from Step 1. The form marks this field optional, but Db2 on Cloud needs it.
  3. Userid: the database userid from Step 1.
  4. Password: the password issued alongside the userid.
5

Choose who can use this connection

Under Sharing, the connection is private to you by default and shows a Private label. To share it, click Share with others. Then add workspace members by email, or click Invite entire workspace to make the connection available to everyone in your Lovable workspace.See Who can use connections and clients for more information.
6

Connect

Click Connect. Lovable verifies the credentials against your Db2 instance before saving the connection.
When connected, anyone building in a project can ask Lovable in the project chat to link their project to IBM Db2 (based on configured connection-level access). Your Lovable apps can then browse your schemas and run SQL on your data. In the project chat, Lovable asks for your approval before it runs each SQL query, including a read-only query. The connector cannot tell a query that reads data from a query that changes data. If you select Always allow, Lovable can run all later queries on that connection without asking. This includes queries that change or delete data. See Approving connector actions in the project chat. A published app does not ask for approval. If the database password changes, open the connection, enter the new Password under Configure connection, and click Update. Lovable verifies the new password with your Db2 instance before saving it.

Limitations

The IBM Db2 connector cannot:
  • Connect to a Db2 server you run yourself. The connector uses the IBM Db2 REST API, which serves managed Db2 instances in IBM Cloud.
  • Page through query results. Each query returns up to a row limit that the app sets. For larger reads, the app can export results as CSV, up to 100,000 rows.
  • Support per-end-user IBM Db2 login. Each connection represents a single database user shared across all projects linked to it.

Manage your IBM Db2 connection

Connections are managed from Connectors: select IBM Db2, then open the connection.
  • Unlink projects to remove IBM Db2 access from specific projects while keeping the connection available for others. See Unlink projects from a connection for the steps.
  • Delete the connection to remove it from the workspace entirely. Deleting is permanent. It removes the credentials from all linked projects, and app features that use IBM Db2 stop working until a new connection is added. See Delete a connection for the steps and who can delete.