I'm trying to insert N"Pepito Malasanya O'Dhogerty" on Python 3 but cannot escape the single quote, the error on PYODBC is:
"Incorrect syntaxis".
I know that I have to add another one (O''Dhogerty) but I did my best trying everything I saw and didn't fix it.
That's what I did so far:
string = string.replace("'", "\\'\\'")
UPDATED:
It didn't work because I was using 'N' front of the string (because I have characters like "ª")
Now I have:
row[0] = row[0].replace("'","\'\'")
pyodbc.ProgrammingError: ('42S22', "[42S22] [Microsoft][ODBC SQL Server Driver][SQL Server]El nombre de columna 'Pepito Malasanya O''Dhogerty' no es válido. (207) (SQ LExecDirectW)")
What am I doing wrong? I'm going to check parameterized query as you said.