Search code examples
pythonjsonbpostgresql-13

Update jsonb column in postgresql


I am trying to update postgres column response_json(type: jsonb) with jsonb data

UPDATE test.product SET response_json={'a': '', 'b': ''} WHERE "product_id"=1

I get ERROR

ERROR: syntax error at or near "{"
  Position: 39

Solution

  • Use Double Quotes "" instead of single quotes '' like this -

    UPDATE  test.product SET response_json='{"a":"" , "b":"" }' WHERE "product_id"=1