How do I filter query results using the WHERE keyword with Redshift python connector?
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.
you need to add single quotes around the string you're filtering for
it would be
= 'git'
and not
= git
Relevant questions
How can I find the Query ID for an Athena Saved Query on AWS console?
asked 4 months agouse Redshift Spectrum to query both Redshift table and s3 file
Accepted Answerasked 2 years agoTransfer from S3 to Redshift and filter specific key
asked 6 months agoHow do I filter query results using the WHERE keyword with Redshift python connector?
Accepted Answerasked 2 months agoUsing Athena to query AWS Lake Formation database
asked a month agoHow do I do single search query?
asked 5 months agoConnecting to Redshift with Python - Operation Timed Out
asked 3 months agoRedshift keeps lock on table after query completed
Accepted Answerasked 3 years agoUsing redshift-data boto3 to make cross account redshift calls
asked 4 months agoI cannot use current_date + interval in Athena boto3 query in Lambda
Accepted Answerasked 3 months ago
(this is true for most SQL-like languages)