-
-
Save richard24se/e3c5b6fc6796bf121b96eda7e43777c3 to your computer and use it in GitHub Desktop.
getFieldsSQLAlchemy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#METHOD TO GET FIELDS FROM MODEL | |
def get_fields_sqlalch(self,cols,model): | |
return [model.__dict__[k] for k in cols] | |
#USE METHOD | |
fields = get_fields_sqlalch(['campo1','campo2'],ColaboradorModel) | |
#APPLY FIELDS TO QUERY | |
result = [o._asdict() for o in s.query(*fields)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment