How to Sink Streaming Data to Apache Iceberg with SQL
Connect Python applications to RisingWave using psycopg2 — the same driver you use for PostgreSQL. Query streaming materialized views like regular database tables.
Installation
pip install psycopg2-binary
Connection
import psycopg2
conn = psycopg2.connect(
host="risingwave-host", port=4566,
dbname="dev", user="root"
)
Query Streaming Views
cursor = conn.cursor()
cursor.execute("SELECT * FROM order_metrics WHERE revenue > 10000")
for row in cursor.fetchall():
print(f"Region: {row[0]}, Revenue: {row[1]}")
With SQLAlchemy
from sqlalchemy import create_engine
engine = create_engine("postgresql://root@risingwave-host:4566/dev")
df = pd.read_sql("SELECT * FROM active_users", engine)
With asyncpg (async)
import asyncpg
conn = await asyncpg.connect("postgresql://root@risingwave-host:4566/dev")
rows = await conn.fetch("SELECT * FROM real_time_metrics")
Frequently Asked Questions
Does any PostgreSQL driver work with RisingWave?
Yes. psycopg2, asyncpg, SQLAlchemy, Django ORM, and any other PostgreSQL-compatible driver works with RisingWave.

