I am trying to connect to MSSQL DB using python from Linux ( Python 2.7 , Ubuntu 11.04 ). The output I get is truncated to 500 characters. Please see the script and configs below. How can this be solved? The problem I suspect in or near the ODBC driver.
Code (pyodbc, pymssql):
conn = pymssql.connect(host='my_remote_host', user='ro_user', password='password', database='current', as_dict=True) cur = conn.cursor() cur.execute(sql) for i in cur: print i conn.close() cnxn = pyodbc.connect(driver='FreeTDS', server='my_remote_host', database='current', uid='ro_user', pwd='password') cursor = cnxn.cursor() cursor.execute(sql) rows = cursor.fetchall() ... cnxn.close()
I do not have write access to MS SQL DB, it is actually a remote server that does not belong to our system.
SQL:
sql = ''' SELECT Req.ID, ShReq.Summary AS [Short Name], ShReq.ALM_SharedText AS [Text], Req.ContainedBy, Req.DocumentID FROM CurMKS..ALM_Requirement Req JOIN CurMKS..ALM_SharedRequirement ShReq ON Req.[References] = ShReq.ID WHERE DocumentID = 1111111'''
The problem is the ShReq.ALM_SharedText field. It is truncated to 255 characters, but using transformations such as convert(text,ShReq.ALM_SharedText) AS TEXT and CAST(ShReq.ALM_SharedText AS TEXT) , I increase the truncation to 500 characters. However, there are fields with longer text than 500 characters, and they are truncated.
ODBC Settings:
/etc/odbc.ini :
[MKS]
/etc/odbcinst.ini :
[FreeTDS] Description=FreeTDS Driver=/usr/lib/odbc/libtdsodbc.so UsageCount=1
/etc/freetds/freetds.conf :
[global] tds version = 8.0 ; dump file = /tmp/freetds.log ; debug flags = 0xffff ; timeout = 10 ; connect timeout = 10 ; text size = 2097152 [mksserver] host = my_remote_host port = 1433 tds version = 8.0 client charset = UTF-8
Any thoughts on how this can be resolved?