Open serednya opened 10 years ago
I need to look if HS2 provides this natively, or else this would be wrapped around cur.getSchema() .
So I managed to ""create"" the description field by just using "getSchema()" after a given sql execution (which still cannot reuse the same cursor: bad code?)
description = tuple((col['columnName'], col['type'], None, None, None, None, None) for col in res)
The first two items ( name and type_code ) are mandatory, the other five are optional and are set to None if no meaningful values can be provided.
I have just opened https://github.com/BradRuderman/pyhs2/pull/43 to add the description field.
Hello,
I'm in need of the field cursor.description. I would do it myself but I don't know how to.
This is a field that exists in many (most?) database modules and is defined in PEP249. [https://www.python.org/dev/peps/pep-0249/#cursor-attributes]
I have made a ""work around"" at my company but its terrible.
The idea was that since I know most queries will be in the form of: "select blah,blahblah,etc from my_awesome_tbl where 1=1" I can do the below to fill the first 2 fields:
Invoke:
Terrible implementation:
Another fun fact: