How to convert a MSSQL time datatype to python time or string? The column in MSSQL server is defined as time(7).
On Windows7, I am using Python3/adodbapi, and column returned as bytes:
sql = 'SELECT top 1 * FROM table1'
with adodbapi.connect('srv') as cn:
with cn.cursor() as cur:
cur.execute(sql)
for row in cur:
print(type(row['col1']))
print(row['col1'])
for c in row['col1']: print(c)
>>> <class 'bytes'>
>>> b'\t\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00'
>>> 9
0
30
0
0
0
0
0
0
0
0
0
How do I convert the python bytes back to time or string?
On linux, I am using Python3/pymssql, and column returned as string, which I can parse into time.
>>> <class 'str'>
>>> 09:30:00.0000000