Created
November 28, 2016 05:29
-
-
Save ResolveWang/ec5b9c1b0ca1a6b55f315475c176946f to your computer and use it in GitHub Desktop.
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
def to_dict(ins): | |
table_columns = ins.__table__.c | |
l = [column.key for column in table_columns] | |
d = {} | |
for k, v in ins.__dict__.items(): | |
if k in l: | |
d[k] = str(v) if v is not None else '' | |
return d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment