import io, psycopg2, json
json_to_write = json.dumps(myobject).replace('\\', '\\\\')
buffer = io.StringIO(json_to_write)
cursor.copy_from(buffer, 'my_table')
psycopg2: Writing JSON objects using copy_from. How to format the json string?