Package: tddbapi
tddbapitddbapiis a DB API module that is a shim overteradatasql, the Teradata provided DB API module.teradatasqlclosely follows Teradata JDBC driver in terms of functionality and behaviors, some of which, arguably aren't quitepythonic.tddbapiattempts to correct this by altering selectedteradatasqlbehavior (APIs) as documented here. The remaining, unaltered, functionality is directly passed through to theteradatasqlmodule.teradatasqlbehaviorFixed-length character column values have incorrect length when accessed in Python. According to Teradata, this isworking as designed.teradatasqlusesOperationalErrorfor all exceptions. According to Python's DB API specification,OperationalErroris reserved for a certain class of errors. Additionally, the exception objectdoesn't provide easy access to theerror codeor theerror messagevalues.has text that includes unformatted stack trace of underlyinggosqldriver. While this may be useful in certain situations, for example, reporting errors back to Teradata, but may not be the best message to display to the users.All SQLINTERVALvalues are returned as Python typestrinstead of more appropriate native Python types, thus working with them is harder in Python. Apparently, this was done because not all SQL INTERVAL data types can be represented by Python'sdatetime.timedeltatype.teradatasqlexposes all internally used names, and thus can pollute thenamespaceif you usefrom teradatasql import *.tddbapibehaviorFixed-length character columns will have any extra spaces beyond their actual definition truncated.Appropriate Exception raised for themost commonerrors. Exception objects:havesqlcodeandsqltextattributes that can be queried directly instead of having to parse the error messageprovide__str__method that produces a human-readable error message and removesgosqlstack-trace informationnote: If you want to ensure that the exception handling logic works withteradatasqlandtddbapi, use an Exception class that is higher in the hierarchy, for example,DatabaseErrororErrorINTERVALvalues are objects of eitherdatetime.timedeltasubclasses, or for themonth basedinterval types, instances ofintsubclasses. Themonth-basedintervals use the total number of months as canonical value, thus allowing comparison between two month-based intervals even if their exact types are different.It's safe to codefrom tddbapi import *without introducing non DB-API names into the current namespaceNotetddbapialways obtains resultset metadata information for all queries. If your application also needs access to resultset metadata, it can be accessed as_metaattribute of the cursor as already-parsed JSON data.Installation and UsageInstalltddbapiusing the standardpiputility:pip install --upgrade tddbapiUsingtddbapiin a Python application is as simple as replacingteradatasqlwithtddbapi. For example:importtddbapiasteradatasqlwithteradatasql.connect(host="whomooz",user="guest",password="please")ascon:withcon.cursor()ascur:cur.execute("SELECT * FROM DBC.DBCINFOV")print(cur.fetchall())Disclaimerstddbapimodule:does notcome with any warranty and the user assumes all risks associated with its usage.isnotendorsed by Teradata.overrides some internalteradatasqlimplementation details. It is possible that a future version ofteradatasqlcan breaktddbapi, at least for a short period.will be kept compatible withteradatasqlon a best-effort basis. If you must have the latestteradatasqlall the timeandcannot live with the risk of breakage, even for a short period, you shouldn't use this module.is available via MIT license, which may be different from the licenses of any of its dependencies (currently onlyteradatasql).