From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Shaan Repswal <shaun(dot)reapswaal(at)gmail(dot)com>, psycopg(at)postgresql(dot)org |
Subject: | Re: DELETE FROM statement not working |
Date: | 2016-03-14 16:58:45 |
Message-ID: | 56E6EDC5.1000007@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 03/14/2016 09:56 AM, Shaan Repswal wrote:
> I was trying to delete a record I got inside my database and so I first
> typed all of this inside the interpreter... It was followed by the error
> mentioned at the bottom. I can't figure this out. Can anyone help me out?
>
> >>> conn = psycopg2.connect("dbname=prototypedb user=postgres
> password=superman123")
> >>> cur = conn.cursor()
> >>> cur.execute("DELETE FROM inventory WHERE name = \"Polyester Direct
> High Gloss\";")
> Traceback (most recent call last):
> File "<pyshell#84>", line 1, in <module>
> cur.execute("DELETE FROM inventory WHERE name = \"Polyester Direct
> High Gloss\";")
> psycopg2.ProgrammingError: column "Polyester Direct High Gloss" does not
> exist
> LINE 1: DELETE FROM inventory WHERE name = "Polyester Direct High Gl...
> ^
Double quotes are for identifiers not string values. So your statement
should be:
"DELETE FROM inventory WHERE name = 'Polyester Direct High Gloss' "
>
> >>> name = "DELETE FROM inventory WHERE name = \"Polyester Direct High
> Gloss\";"
> >>> cur.execute(name)
> Traceback (most recent call last):
> File "<pyshell#86>", line 1, in <module>
> cur.execute(name)
> psycopg2.InternalError: current transaction is aborted, commands ignored
> until end of transaction block
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Dorian Hoxha | 2016-03-14 16:58:52 | Re: DELETE FROM statement not working |
Previous Message | Christophe Pettus | 2016-03-14 16:58:28 | Re: DELETE FROM statement not working |