0

This is the query I tried, but it does not work, it gives me the error as if the column does not exist.

I have the table Gzip_master, it contains the status column but when i try to execute the update it gives me

update_value column does not exist

Here's my code:

update_value = "Scraped"
query = 'UPDATE "Gzip_Master" SET "status"=update_value WHERE status IS null'
self.curs.execute(query)
iz_
  • 15,923
  • 3
  • 25
  • 40
  • ProgrammingError: column "update_value" does not exist LINE 1: UPDATE "Gzip_Master" SET status="update_value" WHERE status ... – Selvakumar R Feb 03 '19 at 15:00
  • above comment is my error, what to do ? i'm trying every thing – Selvakumar R Feb 03 '19 at 15:01
  • you are not saying what language you are using, but i think the problem is that you wanted to place the value of `update_value` inside your query, but instead you put the string there. depending on your language, it might be something like `query = 'UPDATE "Gzip_Master" SET "status"=' + update_value + ' WHERE status IS null'` – Beppo Feb 03 '19 at 15:06
  • i'm using python – Selvakumar R Feb 03 '19 at 15:28

1 Answers1

0

The problem is that the text update_value inside the query-String is just text and does not get replace by the variable value you define above that. Also, the value Scraped you define is a string and not a column name, you need to also mark it in the query string (see the single quotes below; you need escape them with a \ as they appear inside a single-quoted string themselves). Try like this:

update_value = "Scraped"
query = 'UPDATE "Gzip_Master" SET "status"=\'' + update_value + '\' WHERE status IS null'
self.curs.execute(query)

There are many other ways to put the value of update_value into the string.

Beppo
  • 176
  • 7