Hi Cedric, with [Column(table1, f) for f in ["field2", "field3"]], is it possible to do column aliases this way?
I'm looking at your codebase and it doesn't appear to be so. I'm looking for Column(table, column_name, select_alias) so that "select_alias" is the column name for "column_name" in the result set. Thank you, On Wed, Mar 20, 2019 at 9:37 AM Brosefski <paul.bro...@gmail.com> wrote: > Thanks Cedric! > > I do have one more question actually. What is the technology you're using > that allows direct parsing of where statements? I find this interesting > from python and I haven't come across another example of it or > documentation on it. > > On Tue, Mar 19, 2019 at 11:56 PM 'Cédric Krier' via python-sql < > python-sql@googlegroups.com> wrote: > >> 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) >> >> -- >> Cédric Krier - B2CK SPRL >> Email/Jabber: cedric.kr...@b2ck.com >> Tel: +32 472 54 46 59 >> Website: http://www.b2ck.com/ >> >> -- >> You received this message because you are subscribed to the Google Groups >> "python-sql" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to python-sql+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "python-sql" group. To unsubscribe from this group and stop receiving emails from it, send an email to python-sql+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.