y 是一位
问题精灵
Recap 2024
发布:
2问题
3评论
热门帖子:
67
触达人数
用户个人简介
404 – 找不到个人简介
会员起始日期:七月 7

It's also possible to simply put the driver on the driver path. Isn't this configuration of the driver too cumbersome

driver = '/usr/irisodbc/bin/libirisodbc35.so'
server = ''
database = ''
username = ''
password = ''
port = ''


cnxn = pyodbc.connect(driver=driver, server=server,port='1972', database=database, uid=username, pwd=password,charset='UTF-8')
###ensure it reads strings correctly.
cnxn.setdecoding(pyodbc.SQL_CHAR, encoding='utf8')
cnxn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf8')
cnxn.setencoding(encoding='utf8')
cursor = cnxn.cursor()
cursor.execute("select top 10 * from xx.xx")
row = cursor.fetchone()
while row:
    print(row)
    row = cursor.fetchone()

cnxn.close()

这个比odbc连接坑少,我使用odbc在linux中查到的字段都是空字符串,如下:

python3 /home/code/httpTest2.py
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
('', '', '', '', None, '')
认证与 Credly 徽章:
y 还没有认证与 Credly 徽章.
Global Masters 徽章:
y 还没有 Global Masters 徽章。
关注者:
y 还没有关注者。
正在关注: