I am running through a very large data set with a json object for each row. And after passing through almost 1 billion rows I am suddenly getting an error with my transaction.
I am using Python 3.x and psycopg2 to perform my transactions.
The json object I am trying to write is as follows:
{"message": "ConfigManager: Config if valid JSON but doesn't seem to have the correct schema. Adopting new config aborted."}
and psycopg2 is reporting the following:
syntax error at or near "t"
LINE 3: ...": "ConfigManager: Config if valid JSON but doesn't seem to ...
I am aware that the problem is the single quote, however I have no idea of how to escape this problem so that the json object can be passed to my database.
My json column is of type jsonb and is named first_row
So if I try:
INSERT INTO "356002062376054" (first_row) VALUES {"message": "ConfigManager: Config if valid JSON but doesn't seem to have the correct schema. Adopting new config aborted."}
I still get an error. And nothing I seem to do will fix this problem. I have tried escaping the t with a \ and changing the double quotes to single qoutes, and removing the curly brackets as well. Nothing works.
I believe it's quite important that I am remembering to do
`json.dumps({"message": "ConfigManager: Config if valid JSON but doesn't seem to have the correct schema. Adopting new config aborted."})` in my python code and yet I am getting this problem.
'and put values with quotes. or use different quotes, like$not_sgl_quote$or better prepare statement and then pass value$doesn't seem to workINSERT INTO "356002062376054" (first_row) VALUES e'{"message": "ConfigManager: Config if valid JSON but doesn\'t seem to have the correct schema. Adopting new config aborted."}'INSERT INTO "356002062376054" (first_row) SELECT e'{"message": "ConfigManager: Config if valid JSON but doesn\'t seem to have the correct schema. Adopting new config aborted."}'INSERT INTO "356002062376054" (first_row) values (E'{"message": "ConfigManager: Config if valid JSON but doesn\'t seem to have the correct schema. Adopting new config aborted."}');