'Missing headers reading Oracle data in Python

I would like to connect to Oracle DB data from Python. I did so with code:

import cx_Oracle

CONN_INFO = {
    'host': 'xxx.xx.xxx.x',
    'port': 12345,
    'user': 'user_name',
    'psw': 'my_password',
    'service': 'abc.xyz.com',
}

CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)

connection = cx_Oracle.connect(CONN_STR)

c = connection.cursor()
rs = c.execute('select * from my_table')

df = pd.DataFrame(rs)

However, I notice that all the headers are missing, and are instead replaced by 0, 1, 2, 3, ... This answer suggests changing pagesize but will this change the Oracle setting? I would like to avoid making any changes in the Oracle DB. Is there a way to solve this?



Solution 1:[1]

Using pd.read_sql instead seems to work:

query = """select * from my_table"""
df_ora = pd.read_sql(query, con=connection)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 nilsinelabore