Skip to content

read_sql function eats informative error messages. #7730

Closed
@chrisgrimm

Description

@chrisgrimm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error ReportingIncorrect or improved errors from pandasIO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions