on 2022 Dec 10 8:31 PM
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:

When debugging I get this
(Pdb) cursor.description
(('Id', <sybpydb.datatyp object at 0x7fb98f73b950>,4, 0 0 0),('Prop2',<sybpydb.datatyp ...
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.
Request clarification before answering.
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
Regards,
Ryan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.