0

If my result field has 2 single quotes then pyodbc encloses the field in double quotes. Otherwise the result in enclosed in single quotes. The double quotes are causing an issue when I try to insert this data into MS SQL Server.

('SAM', "O''Brien, Sam", '2016-06-21 14:05')
('JIM', 'Stover, Jim', '2016-06-21 14:05')

Is there a parameter for pyodbc to override this default behavior?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
andy
  • 1
  • 1
    What issues are being caused? That's just how Python represents string literals that contain quotes, I don't think it has anything to do with `pyodbc` specifically. – jonrsharpe Feb 14 '17 at 21:54
  • Thank you for letting me know it is not pyodbc I should be looking at – andy Feb 14 '17 at 23:22
  • *"The double quotes are causing an issue when I try to insert this data into MS SQL Server."* - You shouldn't be using the string representation of the data to perform inserts; you should be using a *parameterized* insert and just passing the data as the parameter values. That way, you don't have to worry about delimiters, locale issues, etc.. – Gord Thompson Feb 15 '17 at 12:36

0 Answers0