Skip to main content
the user used 3 spaces, like a heretic
Source Link
Felipe Valdes
  • 2.3k
  • 1
  • 18
  • 33

You could just output your object as a dictionary:

class User:
    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

You could just output your object as a dictionary:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

You could just output your object as a dictionary:

class User:
    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

formatting
Source Link
MarredCheese
  • 21.3k
  • 12
  • 109
  • 105

You could just output your object as a dictdictionary:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict()User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

You could just output your object as a dict:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

You could just output your object as a dictionary:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

You could just output your object as a dict:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?How to convert SQLAlchemy row object to a Python dict?

You could just output your object as a dict:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

You could just output your object as a dict:

class User:
   def as_dict(self):
       return {c.name: getattr(self, c.name) for c in self.__table__.columns}

And then you use User.as_dict() to serialize your object.

As explained in How to convert SQLAlchemy row object to a Python dict?

Source Link
charlax
  • 26.1k
  • 19
  • 64
  • 71
Loading