encoding/decoding issue with python2.5 and pymssql

Tzury Bar Yochay Afro.Systems at gmail.com
Mon Mar 24 06:33:58 CET 2008


hi,

in my table the field row_id is type of uniqueidentifier.

when try to fetch the data, pymssql somehow, encodes the values in a
way which yields odd results.

for example:
the value
'EE604EE3-4AB0-4EE7-AF4D-018124393CD7'
is represent as
'\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7'

the only way I manged to pass this is by converting the value into
varchar at the server side.
I would like to solve this at the python side and not in the database
for several obvious reasons

see example:

>>> conn = mymssql.connect(**connection_details)
>>> cur = conn.cursor()
>>> sql = "select row_id, cast(row_id as varchar(36)) from table_a"
>>> cur.execute(sql)
>>> rows = cur.fetchall()
>>> rows[0]
('\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7', 'EE604EE3-4AB0-4EE7-
AF4D-018124393CD7')
>>>
>>>



More information about the Python-list mailing list