python - Cannot write a specific string into a mssql database -
i new databases , python. read many logfiles script , write data mssql express database , use pymssql. logfiles in .csv format , looks this:
id;request
3gix2v2h2mjmmybrf4p5blbm;49db032f0a144efeb1e0e690b4e6a26f; kzbcaakb2ex44dnhrqi4kgvt;28042afb61b44c539fbaa1ac4c303665;
the id , request defined varchar(50) in database.
my script works fine , write 70000 entries in db, till in 1 of logfiles line values:
0xaf3azaza5sb1ztogqfdmwb;934d4978a40c451b8f4080791f752453
appears. error:
pymssql.programmingerror: (102, "incorrect syntax near 'zaza5sb1ztogqfdmwb'.db-lib error message 20018, severity 15)
this script:
for filename in os.listdir(sfolderlocation): if "archive" in filename: open(sfolderlocation + os.sep + filename, 'r') f: reader = csv.reader(f,delimiter=';') skipfirstline = true row in reader: werte=[] if skipfirstline: skipfirstline = false continue werte.append(row[0]) #id werte.append(row[1]) #maprequest werte=tuple(werte) cursor.execute( "insert webgis_test (sessionid,maprequestid) values (%s, %s)", werte) conn.commit() is "0xaf3a" somehow interpreted hex , error? can me fix this? thank
when else sees in code can make better, hear tips :)
thanks dan guzman. literal not encloesd in quotes.
this python code works:
cursor.execute( "insert webgis_test2 (sessionid, maprequestid) values ('"+werte[0]+"','"+werte[1]+"');")
Comments
Post a Comment