This is the sample code: It should dump all the certificates to the
certs directory...
What I suspect is that python thinks that the certif field is a STRING
and it's truncated when the first '\0' occurs...
(The data is stored completely in the database as an equivalent
C-program works fine...)
Sample output:[('csernum', 'STRING', 80, 80, 0, 0, 0), ('certif', 'STRING', 0,
2147483647, 0, 0, 0)]
csernum
certif
import dbi, odbc
def ReadCmail():
result = { 'Result' : 'OK' }
# Microsoft Visual FoxPro ODBC DNS
# Database type: Free table directory
dbc = odbc.odbc('CEC')
cursor = dbc.cursor()
query = "SELECT CSERNUM,CERTIF FROM C_MAIL"
cursor.execute(query)
row = cursor.fetchone()
for row in iter(cursor.fetchone, None):
# Dump certif to file
FileName="C:\\CERTS\\%s.crt" % row[0]
CertFile = open(FileName, "wb")
CertFile.write(row[1])
CertFile.close()
print cursor.description
for tup in cursor.description:
print tup[0]
cursor.close()
dbc.close()
return result
ReadCmail()