I need to dynamically arm the part where the .query()
gets the class of the objects and their attributes, that is, that within query
dynamically insert the tables and columns received from another application. For example:
session.query(CcSipUser.id).all()
I return the column "id" from the table "CcSipUser", if I want other objects I do the following session.query(CcSipUser.id, CcSipUser.name).all()
.
But I need to arm the script depending on the values that happen to me, if with that same table they want "name", "id" or another column of the table.
I am using this form also to transform the values that happen to an object with its attribute.
columnasid = getattr(CcSipUser, "id")
columnasusr = getattr(CcSipUser, "username")
session.query(columnasusr, columnasid).all()
Equivalent to what I wrote earlier, but how could I insert them between the parentheses?