Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cursor.description cuts of column for sql functions #243

Open
SusanneBo opened this issue Nov 8, 2024 · 0 comments
Open

cursor.description cuts of column for sql functions #243

SusanneBo opened this issue Nov 8, 2024 · 0 comments

Comments

@SusanneBo
Copy link

SusanneBo commented Nov 8, 2024

Driver version

redshift-connector==2.1.1

Redshift version

Redshift 1.0.77292

Client Operating System

Windows 11

Python version

Python 3.9.5

Table schema

select
GS_PE
SC_PE
SUM(SALDO_EUR)
from
Table

Problem description

  1. Expected behaviour:
    When we use functions such as sum() the query result should display the exact column name like we have defined in the SQL-Query
  2. Actual behaviour:
    When we use functions such as sum() the query result is missing the column name within the functions brackets
  3. Error message/stack trace:
    No error message for this issue.
  4. Any other details that can be helpful:

Result:

('gs_pe', 1043, None, None, None, None, None)
('sc_pe', 1043, None, None, None, None, None)
('sum', 1700, None, None, None, None, None)

Expected Result:

('gs_pe', 1043, None, None, None, None, None)
('sc_pe', 1043, None, None, None, None, None)
('sum(saldo_euro)', 1700, None, None, None, None, None)

Python Driver trace logs

Sorry, I have no privileges to create tables on the Redshift DB.

Reproduction code

with conn.cursor() as cur:
    cur.execute(sql)
    tuples_list = cur.fetchall()
    dataframe = pd.DataFrame(tuples_list, columns=[desc[0] for desc in cur.description], dtype="object")
    for field in cur.description:
        print(field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant