Skip to content

Column names in cursor.description contain unnecessary characters #25

@meih

Description

@meih

Driver version

2.0.876

Redshift version

Redshift 1.0.23412

Client Operating System

Mac OS 10.15.7

Python version

3.9.1

Table schema

bookname varchar
author‎ varchar

Problem description

  1. Expected behaviour:
    When the table has columns bookname and author, column names in cursor.description are also available as bookname and author.

  2. Actual behaviour:
    What I got from cursor.description were b'bookname' and b'author\xe2\x80\x8e' .

  3. Error message/stack trace:
    No error message for this issue.

  4. Any other details that can be helpful:
    See the reproduction code.

Python Driver trace logs

No trace for this issue.

Reproduction code

Code

# This is the same as the sample code on README
cursor: redshift_connector.Cursor = conn.cursor()
cursor.execute("create Temp table book(bookname varchar,author‎ varchar)")
cursor.executemany("insert into book (bookname, author‎) values (%s, %s)",
                    [
                      ('One Hundred Years of Solitude', 'Gabriel García Márquez'),
                      ('A Brief History of Time', 'Stephen Hawking')
                    ]
                  )
cursor.execute("select * from book")

result: tuple = cursor.fetchall()
print(result)

#  This is the piece of code that I added:
for field in cursor.description:
  print(field)

Output

(['A Brief History of Time', 'Stephen Hawking'], ['One Hundred Years of Solitude', 'Gabriel García Márquez'])
(b'bookname', 1043, None, None, None, None, None)
(b'author\xe2\x80\x8e', 1043, None, None, None, None, None)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions