Skip to main content

ArpeTeradata — Examples & recipes

Copy-paste snippets for the common tasks. All assume the driver is loadable by name (driver="arpeteradata"), which the installer sets up through an arpeteradata.toml manifest. Otherwise, use Loading by explicit path. For the full option reference behind each db_kwargs, see Connection.


Connect and query to Arrow​

The same recipe in every ADBC client. The driver is loaded by name (arpeteradata) and configured with discrete options, so only the language changes:

import adbc_driver_manager.dbapi as dbapi

with dbapi.connect(
driver="arpeteradata",
db_kwargs={
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.username": "alice",
"adbc.arpeteradata.password": "<pw>",
},
autocommit=True,
) as conn, conn.cursor() as cur:
cur.execute("SELECT TOP 10 * FROM SALES.ORDERS")
table = cur.fetch_arrow_table() # pyarrow.Table
print(table.schema)
Autocommit in Python

dbapi.connect() turns autocommit off by default, which opens a Teradata transaction. The recipes on this page pass autocommit=True for reads; when you write with autocommit off, call conn.commit() before closing, or the work is rolled back.

Straight to pandas / Polars​

The result is already Arrow, so these handoffs need no row-by-row conversion. pandas and Polars read straight from the ADBC connection:

Python
import adbc_driver_manager.dbapi as dbapi
import pandas as pd
import polars as pl

db_kwargs = {
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.username": "alice",
"adbc.arpeteradata.password": "<pw>",
}

with dbapi.connect(driver="arpeteradata", db_kwargs=db_kwargs, autocommit=True) as conn:
# pandas: Arrow-backed dtypes, no Python-object columns
df = pd.read_sql(
"SELECT * FROM SALES.ORDERS WHERE order_date >= DATE '2026-01-01'",
conn, dtype_backend="pyarrow",
)

# Polars: reads the same ADBC result directly
pf = pl.read_database(
"SELECT * FROM SALES.ORDERS WHERE order_date >= DATE '2026-01-01'", conn
)

Parameter binding​

Use ? placeholders. The driver sends the values as typed parameters (see Bound parameters):

with conn.cursor() as cur:
cur.execute("SELECT * FROM SALES.ORDERS WHERE order_id = ?", parameters=[42])
row = cur.fetch_arrow_table()

Several parameter rows in one call (Python's executemany) are packed into as few requests as possible:

Python
with conn.cursor() as cur:
cur.executemany(
"INSERT INTO t(a, b) VALUES (?, ?)",
seq_of_parameters=[(1, "x"), (2, "y"), (3, "z")],
)
conn.commit() # needed when autocommit is off (the dbapi default)

For a SELECT, the bound rows must fit in one request (about 1 MB).

Bulk ingest an Arrow table​

adbc_ingest loads an Arrow table into Teradata through packed, parameterised INSERT requests (since v0.3.2). Tables the driver creates are MULTISET and NO PRIMARY INDEX (see Compatibility → Bulk ingest):

import pyarrow as pa

table = pa.table({
"id": pa.array([1, 2, 3], pa.int32()),
"name": pa.array(["a", "b", "c"], pa.string()),
})

with dbapi.connect(driver="arpeteradata", db_kwargs=db_kwargs, autocommit=True) as conn:
with conn.cursor() as cur:
cur.adbc_ingest("my_table", table, mode="create") # create | append | replace | create_append

With autocommit on, all rows load in one transaction: all or none. Strings become VARCHAR(4000) CHARACTER SET UNICODE columns; for longer strings, raise the width on the statement, because a longer value is truncated silently in Teradata session mode:

Python
with conn.cursor() as cur:
cur.adbc_statement.set_options(**{"adbc.arpeteradata.ingest.varchar_length": "16000"})
cur.adbc_ingest("my_table", table, mode="replace")

Ingest into another database or a volatile table with the statement options adbc.ingest.target_db_schema / adbc.ingest.temporary (Python: adbc_ingest(..., db_schema_name="SALES") / temporary=True). Table and column names are quoted as given.

Export a query to Parquet​

Python
import pyarrow.parquet as pq

with dbapi.connect(driver="arpeteradata", db_kwargs=db_kwargs, autocommit=True) as conn, \
conn.cursor() as cur:
cur.execute("SELECT * FROM SALES.LINEITEM")
reader = cur.fetch_record_batch() # streaming RecordBatchReader
with pq.ParquetWriter("lineitem.parquet", reader.schema) as w:
for batch in reader:
w.write_batch(batch)

Streaming keeps memory flat regardless of result size; batch_size sets the rows per batch (default 32000). The ARPETERADATA:type field metadata travels into the Parquet schema, so the Teradata type of each column is kept.

TLS and logon mechanisms​

Verify the server certificate (recommended on any untrusted network), with a CA file for a gateway certificate signed by an internal CA:

Python
conn = dbapi.connect(driver="arpeteradata", db_kwargs={
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.username": "alice",
"adbc.arpeteradata.password": "<pw>",
"adbc.arpeteradata.sslmode": "verify-full",
"adbc.arpeteradata.sslca": "/etc/ssl/teradata-ca.pem",
}, autocommit=True)

A server without TLS, through TTU on the legacy port, with an explicit TTU directory:

Python
conn = dbapi.connect(driver="arpeteradata", db_kwargs={
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.username": "alice",
"adbc.arpeteradata.password": "<pw>",
"adbc.arpeteradata.sslmode": "disable",
"adbc.arpeteradata.ttu_path": "/opt/teradata/client/20.00/lib64",
}, autocommit=True)

Kerberos single sign-on (after kinit) and JWT, over TLS without TTU:

Python
kerberos = {
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.sslmode": "verify-full",
"adbc.arpeteradata.logmech": "KRB5",
}
jwt = {
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.sslmode": "verify-full",
"adbc.arpeteradata.logmech": "JWT",
"adbc.arpeteradata.logdata": "token=" + token,
}

More in Authentication.

.NET through NuGet​

Besides the installer, the driver is packaged as the native-only NuGet package ArpeTeradata.AdbcDriver: the driver library for linux-x64 and win-x64 under runtimes/<rid>/native/, which NuGet copies into your application's output. It has no managed assembly. The package is not on nuget.org: ask sales@arpe.io for the .nupkg, then add the folder that holds it as a package source:

MyApp.csproj
<PropertyGroup>
<RestoreSources>$(RestoreSources);/path/to/nupkg-folder</RestoreSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ArpeTeradata.AdbcDriver" Version="0.3.5" />
</ItemGroup>

Load the native library from the output directory with the .NET ADBC driver manager, and supply the licence as a database option (or with ARPEIO_ADBC_LICENCE_FILE):

C#
using Apache.Arrow.Adbc;
using Apache.Arrow.Adbc.C;

string lib = OperatingSystem.IsWindows()
? "arpeteradata_adbc_driver-win-x64.dll"
: "libarpeteradata_adbc_driver-linux-x64.so";
using AdbcDriver driver = CAdbcDriverImporter.Load(lib, "AdbcDriverInit");
using AdbcDatabase database = driver.Open(new Dictionary<string, string> {
["adbc.arpeteradata.server"] = "td.example.com",
["adbc.arpeteradata.username"] = "alice",
["adbc.arpeteradata.password"] = "<pw>",
["arpeio.adbc.license_file"] = "/etc/arpeio/arpeio_adbc.lic",
});

Check the name of the library file the package placed in your output directory, and adjust lib if needed.

Loading by explicit path​

Load-by-name uses an arpeteradata.toml ADBC driver manifest on the driver manager's search path (point ADBC_DRIVER_PATH at its directory if needed). Without one, pass the shared library's path as the driver:

Python
conn = dbapi.connect(
driver="/opt/arpeio/libarpeteradata_adbc_driver-linux-x64.so", # Windows: r"C:\arpeio\arpeteradata_adbc_driver-win-x64.dll"
db_kwargs={
"adbc.arpeteradata.server": "td.example.com",
"adbc.arpeteradata.username": "alice",
"adbc.arpeteradata.password": "<pw>",
},
)

In C# use CAdbcDriverImporter.Load("libarpeteradata_adbc_driver-linux-x64.so", "AdbcDriverInit"). Everything after loading is identical. When loading by path, put the licence file arpeio_adbc.lic next to the library, or supply the licence another way (see Licensing).

See also​