How do I filter query results using the WHERE keyword with Redshift python connector?

0

I am using the python connector for Redshift to query my database. Queries work predictably until I attempt to use the WHERE keyword. For example, running the query: "select * from dev.public.test_host WHERE first_column = git" returns

redshift_connector.error.ProgrammingError: {'S': 'ERROR', 'C': '42703', 'M': 'column "git" does not exist in test_host', 'F': '../src/pg/src/backend/parser/parse_expr.c', 'L': '1523', 'R': 'transformColumnRef'}

Another example: "select * from information_schema.tables WHERE table_name = test_host" returns

redshift_connector.error.ProgrammingError: {'S': 'ERROR', 'C': '42703', 'M': 'column "test_host" does not exist in tables', 'F': '../src/pg/src/backend/parser/parse_expr.c', 'L': '1523', 'R': 'transformColumnRef'}

These queries return the correct answer when run in Redshift Query Editor v2. They also return correct answers when run without the 'where' part. Please help.

1개 답변
1
수락된 답변

you need to add single quotes around the string you're filtering for

it would be

= 'git'

and not

= git

AWS
답변함 2년 전
AWS
전문가
검토됨 2년 전
  • (this is true for most SQL-like languages)

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인