Unicode problem from SQL Server DB
Joel Quinet
joel.quinet at be.unisys.com
Tue Dec 11 12:42:44 EST 2001
Hi all,
I have put a pdf file in a binary field in a sql server DB.
When I read it back, I receive the double size of data. I suppose my data
are encoded in unicode.
How can I convert them ??
My test script follow
Thanks
import win32com.client
mServer = '(local)'
mUsr = 'sa'
mPwd = ''
mDb = 'TestDb'
conn = win32com.client.Dispatch(r'ADODB.Connection')
DSN = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" + mUsr +
";" + "Password=" + mPwd + ";Initial Catalog= " + mDb + " ; Data Source=" +
mServer + ""
conn.Open(DSN)
rs = win32com.client.Dispatch(r'ADODB.Recordset')
rs_name = 'select * from TABLE1'
rs.Open(rs_name, conn, 1, 3)
#rs.AddNew
#rs.Fields("Numero").Value = 1
#rs.Fields("Fichier").Value = ''
#f = open ('./frgf00.pdf', 'rb')
#data = f.read()
#print 'Len : ', len(data)
#rs.Fields("Fichier").AppendChunk (data)
#f.close()
#rs.Update()
print rs.Fields("Numero").Value
f = open('./temp.pdf', 'wb')
data = rs.Fields("Fichier").GetChunk (1000000)
f.write ( data )
f.close()
rs.Close()
conn.Close()
More information about the Python-list
mailing list