teradatasql is the official Python driver for connecting to Teradata Vantage and other Teradata systems. It provides a DBAPI 2.0 compliant interface, allowing Python applications to connect to Teradata databases, execute SQL queries, and fetch results. The current stable version is 20.0.0.55. Teradata usually releases updates on an as-needed basis to support new features or address issues.
pip install teradatasqlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to establish a connection to a Teradata database, execute DDL and DML statements, commit changes, and query data using the `teradatasql` driver. It highlights the importance of using `os.environ.get` for sensitive credentials and proper resource management by closing cursors and connections. Note that `autocommit` is `False` by default, requiring explicit `con.commit()`.
Update your code to handle `Decimal` objects where appropriate. If you explicitly need `float` representation for older code, you might need to convert them manually (e.g., `float(decimal_value)`), though this is generally discouraged for precision-sensitive data.
Consult the `teradatasql` documentation for version 20.x to verify connection parameters and default settings. If encountering connection issues, explicitly specify parameters like `logmech` or review the new connection string format for complex configurations.
Always call `con.commit()` after executing statements that modify the database (DML or DDL). Use `con.rollback()` to undo changes in case of an error. Wrap database operations in `try...except...finally` blocks to ensure `commit()` or `rollback()` and `close()` are called.
Always use `try...finally` blocks to ensure `cur.close()` and `con.close()` are called, even if errors occur during database operations. For simple scripts, a `with` statement for connection is not directly supported by `teradatasql`'s connect method, so explicit closing is necessary.
No dependency data recorded yet.