> Markdown version of https://www.artie.com/blogs/ai-data-integration. Site index for AI agents: https://www.artie.com/llms.txt

[Back to blog](https://www.artie.com/blogs)

Data know-how Updated November 18, 2026

# AI Data Integration: How to Build Real-Time Pipelines for AI Agents and Apps

[Jacqueline Cheong Co-founder & CEO](https://www.artie.com/authors/jacqueline-cheong)

[Share on LinkedIn (opens in a new tab)](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fwww.artie.com%2Fblogs%2Fai-data-integration) [Share on X (opens in a new tab)](https://x.com/intent/post?text=AI%20Data%20Integration%3A%20How%20to%20Build%20Real-Time%20Pipelines%20for%20AI%20Agents%20and%20Apps\&url=https%3A%2F%2Fwww.artie.com%2Fblogs%2Fai-data-integration)

AI data integration covers two jobs. One is using machine learning and LLMs to do integration work, like mapping fields and generating pipeline code. The other is getting current data to the AI apps and agents that act on it. This page is mostly about the second job: how changes in your production database reach the tables your AI reads, and what breaks along the way.

## Key Takeaways

* Log-based [change data capture](https://www.artie.com/glossary/change-data-capture) (CDC) streams each committed insert, update and delete from a production database to the tables an agent or model reads. Data that lives in SaaS apps needs a connector or an API job instead.
* At scale, the failures come from deletes that never reach the AI, schema changes under live queries, and a replication slot whose consumer falls behind, which holds WAL until the disk fills.

## What AI Data Integration Means

The term gets used for two different things.

| Meaning            | What it covers                                                                                       | Who it's for                                                 |
| ------------------ | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| AI for integration | Models and agents that write, map and operate integration work for you                               | Teams automating pipeline and mapping work                   |
| Integration for AI | Getting production data to the models, agents and RAG systems that act on it, and keeping it current | Teams shipping an AI feature on top of a production database |

This page covers the second; for agents that build and run pipelines, see the [FAQ](https://www.artie.com/blogs/ai-data-integration#faq).

## Why AI Agents and Fraud Models Need Real-Time Data

A customer writes into your support chat: "Where's my order?" Your AI agent looks up their account in [Snowflake](https://www.snowflake.com/), finds the latest order status, and responds.

Except the data in Snowflake is from last night's batch load. The order shipped two hours ago. The agent tells the customer "your order is being processed" when it's already on a truck, and a human has to step in anyway.

Stale data was fine while AI ran offline, training models or scoring leads overnight. A support agent or a fraud model answers while someone is waiting, so it needs each row as it is now.

A fraud model that scores a card transaction against the balance and account flags from last night's load is scoring the account as it was yesterday. If the balance was drawn down this morning, or the account was frozen an hour ago, the model can't know.

The same problem hits [RAG](https://en.wikipedia.org/wiki/Retrieval-augmented_generation) (Retrieval-Augmented Generation). If your LLM pulls context from a vector index built from last night's tables, it's answering from stale embeddings. A customer deletes their account at 9am and the row is deleted in Postgres, but at 2pm the retriever still returns chunks about them.

Fixing that takes two steps. First, the delete has to reach the warehouse. Then an embedding job has to remove that customer's chunks from the index. **The embedding job is yours**: a CDC pipeline lands rows in tables and stops there.

Postgres – customer's account row is deleted → CDC – delete applied in the warehouse → Your embedding job – removes that customer's chunks → Vector index – retriever stops returning them

Real-time pipelines handle the first step by streaming changes from the source database to the tables your AI depends on as they commit, instead of waiting for a nightly ETL job.

## How a Real-Time Data Pipeline for AI Works

A log-based pipeline from a production database to an AI system has five parts:

1. The source database, such as [Postgres](https://www.postgresql.org/), [MySQL](https://www.mysql.com/) or [MongoDB](https://www.mongodb.com/), where your orders and accounts are written.
2. A CDC reader that follows the database's own change log: the [write-ahead log (WAL)](https://www.artie.com/blogs/postgres-write-ahead-logs) in Postgres, the [binlog](https://dev.mysql.com/doc/refman/8.4/en/binary-log.html) in MySQL, or the oplog, through [change streams](https://www.mongodb.com/docs/manual/changestreams/), in MongoDB. It captures each change as it commits.
3. A durable buffer between the reader and the writer, often [Kafka](https://kafka.apache.org/), so a slow destination doesn't stall capture.
4. A writer that applies the changes to the warehouse, lakehouse or database your AI queries, such as Snowflake, [BigQuery](https://cloud.google.com/bigquery), [Redshift](https://aws.amazon.com/redshift/) or [Databricks](https://www.databricks.com/). For RAG, an embedding job reads these tables and writes the vector index. That job runs after the pipeline, and you own it.
5. The AI system, such as a support agent or fraud model, which queries the destination and gets current data.

Postgres – orders and accounts tables → CDC reader – reads the WAL through a replication slot → Kafka – buffers changes when the destination slows → Writer – MERGE into Snowflake, then commits the offset → AI agent – queries the current row

Back to the support agent: a customer updates their shipping address in your app. The write commits in Postgres, the reader picks it up from the WAL, it passes through Kafka, the writer merges it into Snowflake, and the next time the agent queries that customer's record, the address is current.

### Setting One Up on Postgres

1. Turn on logical decoding. On Amazon RDS, set the `rds.logical_replication` parameter to `1`. On Cloud SQL, set the `cloudsql.logical_decoding` flag to `on`. On self-managed Postgres, set `wal_level` to `logical`. All three need a restart. Check `max_wal_senders` and `max_replication_slots` before you restart, since both are read only at server start and the pipeline uses one of each.
2. Run `SHOW wal_level;` and confirm it returns `logical`.
3. Create a replication role and a [publication](https://www.postgresql.org/docs/current/logical-replication-publication.html). The publication lists the tables the AI needs, and only those tables are streamed. Every table in it needs a primary key or a [`REPLICA IDENTITY`](https://www.postgresql.org/docs/current/sql-altertable.html#SQL-ALTERTABLE-REPLICA-IDENTITY): once a table without one is in a publication that publishes updates and deletes, Postgres rejects `UPDATE` and `DELETE` on it. The role needs the `REPLICATION` attribute, except on RDS, where you grant it the `rds_replication` role instead.
4. Create the replication slot, backfill, then stream from the slot. The slot has to exist before the copy starts, so changes committed during the copy are kept for the stream. The `SELECT` grant lets the pipeline copy the rows already in those tables.

SQL

```
SHOW wal_level;  -- should return 'logical'

-- Self-managed Postgres and Cloud SQL (placeholder password: replace before running)
CREATE ROLE cdc_reader WITH LOGIN REPLICATION PASSWORD 'change-me';

-- Amazon RDS: create the role without REPLICATION and grant rds_replication instead
-- CREATE ROLE cdc_reader WITH LOGIN PASSWORD 'change-me';
-- GRANT rds_replication TO cdc_reader;

GRANT SELECT ON orders, accounts TO cdc_reader;
CREATE PUBLICATION ai_publication FOR TABLE orders, accounts;
```

The Postgres to BigQuery guide covers how to [turn on logical decoding](https://www.artie.com/learn/postgres-to-bigquery) on each platform and which settings (`max_wal_senders`, `max_replication_slots`) to check.

## Getting Customer Data Into AI Models Without Custom ETL

Where the customer data lives decides the tool:

* Your production database (orders, accounts, subscriptions, balances) needs log-based CDC into the warehouse or database the AI queries.
* SaaS apps and third-party APIs (CRM, billing, support tools) need a SaaS ELT connector or the vendor's API on a schedule. How fresh that data gets is set by the vendor's API.
* Product events, like clickstream, go through an event pipeline into the same warehouse.

An agent often reads from more than one of these, so map where each field it uses comes from before you pick anything. To weigh specific tools, [compare real-time pipeline platforms for AI](https://www.artie.com/learn/best-real-time-data-pipeline-platforms-for-ai-applications).

For the database case, a common first version of custom ETL is a cron job:

SQL

```
SELECT * FROM orders WHERE updated_at > :last_run;
```

It misses three kinds of change:

* Hard deletes. A deleted row has no `updated_at` to find, so an account deleted in Postgres stays in the warehouse.
* Intermediate versions. A row that changes three times between runs shows up once, in its last state.
* Writes that skip `updated_at`. A backfill script or a manual fix in psql never shows up.

It also repeats the scan against production on every run, whether anything changed or not. Log-based CDC replaces that cron job, and only that one. It doesn't connect to your CRM or billing system; those still need a connector or an API job.

## How to Build an AI Data Pipeline That Holds Up in Production

Before you pick a tool, decide how the pipeline should handle each of these.

### Source Coverage

Check that the tool reads the log of every database you run in production. Postgres logical replication, the MySQL binlog and MongoDB change streams are separate integrations, and a tool can support one without the others.

### Latency

Vendors use "real time" for different things, so measure it yourself. Write a timestamped row to a heartbeat table on the source, read it in the destination, and alert when the gap grows. For an agent answering customers, sub-minute is the bar.

### Schema Changes

New columns should arrive on their own. Renames and type changes should be flagged to you and not applied silently, because an agent's SQL or a feature pipeline that reads `customer_status` breaks when the column becomes `account_status`. See how [renames and type changes play out in Snowflake](https://www.artie.com/blogs/snowflake-schema-evolution).

### Deletes

Choose hard or soft delete per table. A hard delete removes the row in the destination. A soft delete keeps the row with a flag column, which helps audits, but then every agent query and embedding job has to filter out flagged rows.

### Change History

A current-state table answers "what plan is this customer on?" A history table, with one row per change, answers "what changed since Monday?" Some agents need both: a fraud model may want the current balance and how it moved over the last day. Here's how to build [change history](https://www.artie.com/blogs/how-to-build-audit-logs-using-cdc-and-scd-type-2) with CDC and SCD Type 2.

### Data Quality

A MERGE that succeeds but touches zero rows, or a COPY INTO that loads fewer records than expected, can feed your AI bad data without anyone noticing. [In-flight validation](https://www.artie.com/blogs/improve-data-quality-with-in-flight-data-pipeline-validation) that checks row counts at each pipeline stage catches these before they reach the model.

### Source Load

Decide whether backfills read from the primary or from a read replica, and alert on how much WAL each replication slot holds. On Postgres, this shows what each slot retains:

SQL

```
SELECT slot_name,
       pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS retained_wal
FROM pg_replication_slots;
```

### Observability

Alert per table on how far behind the destination is in time and how many rows are waiting to be applied, so a stuck table shows up before a customer reports a wrong answer.

### How Artie Handles It

[Artie](https://www.artie.com/) is what we built for the database side of this. Artie is managed CDC for production databases. The destination matches production in real time, the source never slows down, and our engineers get paged, not yours. The second diagram above is how it runs.

The source stays light because the reader confirms its LSN to Postgres after every successful write to Kafka (batch size or 10 seconds by default), so `confirmed_flush_lsn` advances and WAL is recycled even when the warehouse is slow. Backfills are bounded reads by primary key, by range or by [ctid scanning](https://www.artie.com/blogs/postgres-ctid-scanning), one statement per batch with no `BEGIN` and no `LOCK TABLE`. The only lock is the `ACCESS SHARE` lock every `SELECT` takes, which doesn't block writes.

Every change goes from the reader through Kafka to the writer, and the writer commits the Kafka offset only after the destination write succeeds, so a crash replays the batch and nothing is lost. On warehouses the writer applies each batch with MERGE or an upsert, so a replayed batch converges to the same rows. In Snowflake, merges keep current-state tables in step, and [Snowpipe Streaming](https://www.artie.com/blogs/the-ultimate-guide-to-snowpipe-vs-snowpipe-streaming) can load the tables Artie appends to, such as history tables. Other destinations include BigQuery, Databricks, Redshift, ClickHouse, Iceberg and Postgres.

Deletes are hard, soft (an `__artie_delete` column) or skipped, set per table. New columns are added at flush time. Dropped columns are removed only if you turn that on, after four hours of absence. A rename arrives as a new column, added at flush time, while the old column stops getting values. A type change isn't applied to the destination column. Both show up in a schema-change summary email, sent weekdays at 6 AM Pacific by default. History mode writes every change to a separate `__history` table.

Artie's on-call is paged for infrastructure failures. You still see the pipeline's state: `artie_ingestion_lag_ms`, `artie_row_lag` and `artie_replication_slot_size_mb` export to Datadog or any Prometheus remote-write endpoint. Artie won't fix bad data at the source, and it doesn't compute embeddings or connect to SaaS apps. It keeps the tables your AI reads current, deletes included.

## Common Challenges When Scaling AI Data Pipelines

These are the ones that show up as an AI feature grows from a few tables to many.

### Schema Drift Under Live Queries

A developer adds a `middle_name` column to the users table, or renames `status` to `account_status`. A pipeline that doesn't expect it either drops the change or stops, and the agent's query against the old column breaks. Pick a pipeline that handles renames and type changes as described under [Schema Changes](https://www.artie.com/blogs/ai-data-integration#how-to-build-an-ai-data-pipeline-that-holds-up-in-production) above, so a rename reaches you in a summary email and not as a failed query.

### Replication Slots Filling the Source Disk

A [replication slot](https://www.artie.com/blogs/postgresql-replication-slots) tracks how far its consumer has confirmed, and Postgres keeps all WAL from the slot's `restart_lsn` onward on disk. With the default `max_slot_wal_keep_size = -1` there's no cap, so a consumer that confirms late, or stops, can fill the production database's disk. A consumer that confirms its position after every flush keeps the slot small. Artie's reader does this. In our benchmark against AWS DMS, after ten minutes at 22,400 events/s, Artie held 385 MB of retained WAL and was flat, while DMS held 6.1 GB and was still growing: [16x less WAL than DMS](https://www.artie.com/blogs/artie-vs-aws-dms).

Backfills are the other source load. Artie's backfills can read from a read replica if you set one in the source's connection settings, while CDC still reads from the primary.

### Backfilling a New Table While the Agent Is Live

When the agent needs a new table, its existing rows have to be copied while production keeps writing. Artie runs the backfill alongside CDC: changes to that table queue in Kafka and apply in order when the backfill completes.

## FAQ

### What is AI data integration?

It has two meanings: using AI to automate integration work, such as schema mapping, and integrating production data so AI apps and agents act on current information.

### Which AI is best for integration?

No single model is best, and for an AI app in production, how current its tables are matters more than which model wrote the pipeline.

### How can AI agents build and maintain data pipelines?

Through the pipeline tool's API or MCP server. With [Artie MCP](https://www.artie.com/blogs/artie-mcp), an agent in Claude Code, Cursor or Codex can create or operate pipelines, start or pause replication, run approved backfills and inspect schema changes. Tools that can make destructive changes are labeled as requiring confirmation. Keep human confirmation turned on in your MCP client, since the client decides whether to ask you before it calls a tool.

### Do all AI systems require real-time data integration?

No. Offline training and weekly batch scoring work fine on scheduled loads; real time matters when the AI acts on live decisions, like answering a customer or catching fraud as it happens.

### What is the difference between batch and real-time pipelines for AI?

Batch pipelines copy snapshots on a schedule, such as hourly or nightly. Real-time pipelines from a database use CDC to stream each committed change, so the AI reads data from the last minute instead of the last load.

### Does fresh data prevent AI hallucinations?

Only the wrong answers caused by stale data, like an agent saying a shipped order is still processing. A model can still make things up from current data.

## Related articles

* ### [ClickHouse Integration: A Practical Guide for Data Teams in 2026](https://www.artie.com/blogs/clickhouse-integration-guide)

  [Jacqueline Cheong Co-founder & CEO](https://www.artie.com/authors/jacqueline-cheong)

* ### [Data & Engineering Innovators Spotlight: John Lang, AI Architect at Valenz Health](https://www.artie.com/blogs/data-engineering-innovators-spotlight-john-lang-valenz-health)

  [Jacqueline Cheong Co-founder & CEO](https://www.artie.com/authors/jacqueline-cheong)

* ### [Building Production-Grade Webhooks with Retries and Streams – Without Breaking Your Data Pipeline](https://www.artie.com/blogs/building-production-grade-webhooks-with-retries-and-streams----without-breaking-your-data-pipeline)

  [Anirudh Sriram Founding Engineer](https://www.artie.com/authors/anirudh-sriram)

## We’re a data company

## Watch your data replicate live

[Start for free](https://app.artie.com/signup) [Book a demo](https://www.artie.com/contact)
