I have a python file that creates and populates a table in ms sql (via modelbuilder). The only sticking point is that the code breaks if there are any non-ascii characters or single apostrophes (and there are quite a few of each). Although I can run the replace function to rid the strings of apostrophes, I would prefer to keep it intact. I have also tried converting the data into utf-8, but no luck there either. The python code is attached as a text file.
An example of the error messages are "'ascii' codec can't encode character u'\2013' in position..." (for non-ascii characters) and "class 'pyodbc.ProgrammingError'>: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Server] Incorrect syntax near 'S, 230 X 90M.; Eligibilty..." (for the single quotes). The python code is included below. I believe the point in the code where this break occurs is after the following line: InsertValue = str(row.GetValue(CurrentField['Name'])).
Any help would be greatly appreciated.
James