I'm looking to address code using sybpydb to connect to ase 16, I see we need to take a closer look at types returned (univarchar fields need special processing). I see sybpydb's cursor provides cursor.description that (as
PEP249
lays out) provides metadata about the columns (name, type_code,display_size,internal_size,precision,call, null_ok).
Would someone be able to provide guidance as to how to interpret type_code or otherwise determine the incoming type ?
PEP249 mentions DBAPITypeObject but I don't see where in sybpydb would support identifying the underlying type... Is there a better reference than ASE Extension Module for Python it simply states:
Checking further , the underlying type for cursor.description[n][1] (type_code) doesn't seem to expose any public properties . Comparing to sybpydb.STRING, BINARY, NUMBER seems to work at first glance but varchar and univarchar but matching STRING.
Hi,
You can check the description to see what they are set to:
create table tabsample (c1 int, c2 varchar(10))
import sybpydb
conn = sybpydb.connect(user='sa', password='password')
cur = conn.cursor()
cur.execute("select * from tabsample")
while True:
row = cur.fetchall()
desc = cur.description
if (not row):
break
dt = desc[0][1]
print(dt == sybpydb.NUMBER)
dt = desc[][1]
print(dt == sybpydb.NUMBER)
cur.close()
conn.close()
output:
True
False
Possible Datatype
Values in sybpydb :
sybpydb.STRING, sybpydb.NUMBER, sybpydb.BINARY,
sybpydb.DATETIME, sybpydb.IMAGE