var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Update JSON field entirely from python
I'm newbie with postgres. I spent a day trying to make it clear, but unfortunately with no success.
I have a table:
I use psycopg2 library to interact with the postres. I don't use any ORM due to I only need a couple of inserts and updates.
CREATE TABLE backlinks (
target varchar(2048) PRIMARY KEY,
refs JSON NOT NULL
Below the python code I use to insert
Where ref_hosts is python dict.
connection = psycopg2.connect(...)
cursor = connection.cursor
cursor.execute("insert into backlinks (target, refs) values (%s, to_json(%s))",
The insert works as expected, but I can't figure out how to update the JSON field entirely.
I try the code as follows, but it seems it doesn't work.
Where am I wrong?
cursor.execute("update backlinks set refs = to_json(%s) where target = %s",
I'm on Ubuntu 14.04 with Postrges 9.3.13.
Thanx in advance.
UPDATED: I really confused, some records are updated, but other left original. Also I have no error while cursor.execute().
Last edited by 4xy; 06-29-16 at 14:18.
Tags for this Thread