pd.read_sql(sql) If sql has two columns of the same field, the result is only one column of fields

28 Views Asked by At

pd.read_sql(sql) If sql has two columns of the same field, the result is only one column of fields

pd.read_sql() dont work ?

import pandas as pd

sql = "select name, name, age from table;"
df = pd.read_sql(sql, con)

print(df.columns) 
# name, age

it work

with conn.cursor() as a:
    a.execute(sql)
    lines = a.fetchall()
df = pd.DataFrame(lines)
0

There are 0 best solutions below