Closed
Description
Consider the following code.
import pandas as pd
import psycopg2
bad_query = 'select bad_column from my_table;'
conn = psycopg2.connect(...)
pd.read_sql(bad_query, conn)
Running the above in my environment produces a DatabaseError exception with the following message:
"Execution failed on sql: select bad_column from my_table;"
However, when I run the below code to query the database:
import psycopg2
bad_query = 'select bad_column from my_table;'
conn = psycopg2.connect(...)
conn.cursor().execute(bad_query)
The following ProgrammingError message is returned:
"column "bad_column" does not exist in my_table"
This information is helpful for debugging, especially as queries become more complicated, and I believe it should be propagated through to the user.