Reputation: 65
I am trying to understand what each field in the tuple returned from curs.description so I can know what the type is and parameters of that type.
See the code samples below. I basically will run some query and then print or manipulate the cursor description (which is a tuple). What does the data mean (I know one of the fields is the column name)? I want to understand what all these fields mean so I can parse any type information as needed.
for example, here is an SAP HANA query
select *
from "_NAMESPACE"."SomeTable"
which I run from python
conn01 = pyhdb.connect(host='', port=, user='', password = '')
curs02 = conn01.cursor()
curs02.execute(myQuery)
curs02.fetchone()
print(curs02.description) # prints tuple
Returns (for example):
(('FROM_SITE', 11, None, 1, 0, None, 2), ('TO_SITE', 11, None, 1, 0, None, 2), ('FROM', 11, None, 4, 0, None, 0), ('TO', 11, None, 4, 0, None, 0), ('TRX', 11, None, 2, 0, None, 0), ('ACCNUM', 11, None, 8, 0, None, 0), ('DESC', 11, None, 20, 0, None, 2), ('DMYNUM', 3, None, 10, 0, None, 0))
I would like to understand what all the fields within each tuple element is. For example, ('FROM_SITE', 11, None, 1, 0, None, 2). E.g., what is each field signify. "11" seems to signify varchar, but I don't understand all of these.
Upvotes: 2
Views: 9471
Reputation: 3607
The type_code numbers returned by pyhdb
are HANA specific. The number directly corresponds with the type code field returned by the HANA server in the network protocol. This number can change, depending on the client and server version, even if the corresponding column type appears the same.
A list of the known type_code numbers can be found in the pyhdb
source code:
https://github.com/SAP/PyHDB/blob/master/pyhdb/protocol/constants/type_codes.py
Upvotes: 2
Reputation: 2459
The values are:
name
type_code
display_size
internal_size
precision
scale
null_ok
Per the DB-API documentation.
Note that, depending on the DBMS in use, the type_code
that is returned may not conform to the DB-API specification.
Upvotes: 6