Below code works fine
table = Table('user_data',metadata,autoload=True,autoload_with=conn)
stmt = select([table.columns.user_id,table.columns.username])
results = conn.execute(stmt).fetchall()
print(results)
But when i try to pass the columns as list (from postresql db) it fails
cols = get_table_cols() -- it returns a list -> [table.columns.user_id,table.columns.username]
stmt = select(cols )
results = conn.execute(stmt).fetchall()
print(results)
Error:
sqlalchemy.exc.ArgumentError: Textual column expression 'table.c.username' should be explicitly declared with text('table.c.username'), or use column('table.c.username') for more specificity
Kindly provide inputs on the same