What is the most efficient way to populate class attributes with a row from a database query?
Posted
by ensnare
on Stack Overflow
See other posts from Stack Overflow
or by ensnare
Published on 2010-03-30T04:36:15Z
Indexed on
2010/03/30
4:43 UTC
Read the original article
Hit count: 207
Looking to have a database query set all the instance variables in a class:
Example:
def populate(self, if):
#Perform mysql query
self._name = row['name']
self._email = row['email']
...
What's the fastest way to do this? Or is this not recommended (with a better approach)?
Thanks.
© Stack Overflow or respective owner