You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the SavetoMySQLPipeline class in the pipelines.py file tries to insert a record with a single quote, an error is being thrown and the record is rejected. This is because MySQL throws single quotes to begin and end a string value in its insert statement. In order to insert a string with a quote you must use '' (two single quotes in a row). The bad insert statement is being created on line 141 of the pipelines.py file. To fix this I updated the code on line 135:
text = item['text']
with the following code to replace each single quote with two single quotes:
text = item['text'].replace(''', '''')
This could be added to the other variables there for completeness, but wasn't necessary in my case.
Thanks for publishing this!
The text was updated successfully, but these errors were encountered:
When the SavetoMySQLPipeline class in the pipelines.py file tries to insert a record with a single quote, an error is being thrown and the record is rejected. This is because MySQL throws single quotes to begin and end a string value in its insert statement. In order to insert a string with a quote you must use '' (two single quotes in a row). The bad insert statement is being created on line 141 of the pipelines.py file. To fix this I updated the code on line 135:
text = item['text']
with the following code to replace each single quote with two single quotes:
text = item['text'].replace(''', '''')
This could be added to the other variables there for completeness, but wasn't necessary in my case.
Thanks for publishing this!
The text was updated successfully, but these errors were encountered: