I'm trying to insert a network path as a string value using Pypyodbc:
def insert_new_result(self, low, medium, high, reportpath):
reportpath = "'" + reportpath + "'"
self.insertsql = (
"""INSERT INTO [dbo].[Results] ([low],[medium], [high], [date]) VALUES
({low},{medium},{high}, GETDATE(),{reportpath})"""
.format(low=low, medium=medium, high=high, reportpath=reportpath))
self.conection.cursor().execute(self.insertsql).commit()
This is evaluating to
'INSERT INTO [dbo].[Results] ([low],[medium], [high], [date]) VALUES
(0,2,2, GETDATE(),\\'\\\\share\\dev-temp\\report_10b29ef6-7436-11e6-ab96-534e57000000.html\\')'
Notice the extra single quote at the start of the share path, causing an invalid sql error. I have tried a few things like .format(), building the string and escaping however it keeps including the single quote after the first \\.
How can I get self.insertsql to evaluate to
'INSERT INTO [dbo].[Results]
([low],[medium], [high], [date])
VALUES
(0,2,2, GETDATE(),'\\\\share\dev-temp\report_10b29ef6-7436-11e6-ab96-534e57000000.html\')'