On 2019-03-19 21:12, Brosefski wrote:
> I'm not sure how I would do this but I was wondering if there was a
> programmatic way to select items from a list.
>
> Ie: I have a table:
> table1 = Table("table1", "public")
>
> and I have a list of fields names like so:
> ["field1", "field2"]
>
> I would like to be able to feed that list rather than type out the select
> explicitly. What this allows me change what I'm selecting dynamically.
Yes you can. You could use getattr on Table instance but there is a risk
that the attribute name collide with an attribute of the class.
So the best option is to instantiate columns:
columns = [Column(table1, f) for f in ["field1", "field2"]]
query = table1.select(columns)