Write Results Back - Teradata AI Studio

Teradata® AI Studio - Open Python Framework

Product
Teradata AI Studio
Release Number
1.3
Published
July 2026
ft:locale
en-US
ft:lastEdition
2026-07-28
dita:mapPath
rmu1782935249910.ditamap
dita:ditavalPath
ayr1485454803741.ditaval
dita:id
cgn1782251337635
import ray
import teradatasql

# Sample dataset — any Ray Dataset works (from_items, from_pandas, read_csv, …)
ds = ray.data.from_items([
    {"id": 1, "name": "alice", "score": 10.5},
    {"id": 2, "name": "bob",   "score": 20.25},
    {"id": 3, "name": "carol", "score": 30.125},
])

# One INSERT with '?' placeholders per column, in the dataset's column order.
ds.write_sql(
    'INSERT INTO "demouser"."write_demo" (id, name, score) VALUES (?, ?, ?)',
    connection_factory=teradatasql.factory(
        host="<hostname>",
        user="<db_username>",
        password="<db_password>"
    ),
)