KeyError: self._index[x]

From: tango ward <tangoward15(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: KeyError: self._index[x]
Date: 2018-05-08 03:07:55
Message-ID: CAA6wQLJGd-c8rqAetCrk4QMAqFGaX-dqTMVAc934PptvrKqVrg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Good day,

Apologies for asking again.

I am trying to remove the whitespace on student number by using TRANSLATE()
inside the execute() of psycopg2. Problem that I am getting is, even if I
will just print the row with the column name(e.g. row['snumber']), I am
getting KeyError error message. The code works if i will print the row with
index value(e.g. row[0])

`
cur_p = conn_pr(cursor_factory=psycopg2.extras.DictCursor)
cur_t = conn_t.cursor(cursor_factory=psycopg2.extras.DictCursor)

cur_t.execute("""
SELECT TRANSLATE(snumber, ' ', '')
FROM sprofile """)

for row in cur_t:

`

Responses

Browse pgsql-general by date

  From Date Subject
Next Message tango ward 2018-05-08 03:11:15 Re: KeyError: self._index[x]
Previous Message tango ward 2018-05-07 23:44:25 Re: psycopg2.DataError: invalid input syntax for integer: ""