Pythonic shim over teradatasql, Teradata DB API driver
tddbapi is a DB API module that is a shim over teradatasql, the Teradata provided DB API module.
teradatasql closely follows Teradata JDBC driver in terms of functionality and behaviors, some of which, arguably aren't quite pythonic.
tddbapi attempts to correct this by altering selected
teradatasql behavior (APIs) as documented here. The remaining, unaltered, functionality is directly passed through to the
Fixed-length character column values have incorrect length when accessed in Python. According to Teradata, this is working as designed.
OperationalErrorfor all exceptions. According to Python's DB API specification,
OperationalErroris reserved for a certain class of errors. Additionally, the exception object
- doesn't provide easy access to the error code or the error message values.
- has text that includes unformatted stack trace of underlying gosql driver. 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.
INTERVALvalues are returned as Python type
strinstead 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's
teradatasqlexposes all internally used names, and thus can pollute the namespace if you use
from teradatasql import *.
Fixed-length character columns will have any extra spaces beyond their actual definition truncated.
Appropriate Exception raised for the most common errors. Exception objects:
sqltextattributes that can be queried directly instead of having to parse the error message
__str__method that produces a human-readable error message and removes
- note: If you want to ensure that the exception handling logic works with
tddbapi, use an Exception class that is higher in the hierarchy, for example,
INTERVALvalues are objects of either
datetime.timedeltasubclasses, or for the month based interval types, instances of
intsubclasses. The month-based intervals 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 code
from tddbapi import *without introducing non DB-API names into the current namespace
tddbapi always obtains resultset metadata information for all queries. If your application also needs access to resultset metadata, it can be accessed as
_meta attribute of the cursor as already-parsed JSON data.
Installation and Usage
tddbapi using the standard
pip install --upgrade tddbapi
tddbapi in a Python application is as simple as replacing
tddbapi. For example:
import tddbapi as teradatasql with teradatasql.connect(host="whomooz", user="guest", password="please") as con: with con.cursor() as cur: cur.execute("SELECT * FROM DBC.DBCINFOV") print(cur.fetchall())
- does not come with any warranty and the user assumes all risks associated with its usage.
- is not endorsed by Teradata.
- overrides some internal
teradatasqlimplementation details. It is possible that a future version of
tddbapi, at least for a short period.
- will be kept compatible with
teradatasqlon a best-effort basis. If you must have the latest
teradatasqlall the time and cannot 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 only
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size tddbapi-0.1.1-py3-none-any.whl (14.3 kB)||File type Wheel||Python version py3||Upload date||Hashes View|