[sqlalchemy] Re: resultset print keys values
object-query or plain query? - objects are .. whatever class it is; print the i.__dict__ or str(i) or whatever - plain-sql-query ones are RowProxy, they have i.keys() i.items() i.values() On Tuesday 10 February 2009 21:27:09 Lukasz Szybalski wrote: Hello, Could somebody tell me how can I print the object data in my result set without knowing the column names? myresult=session.query(...).all() for i in myresult: print I need to debug some data and its hard to print the object keys and values (column names and its values) . i.keys() ? i.items()? some dictionary like functions would be nice. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: resultset print keys values
On Tue, Feb 10, 2009 at 1:32 PM, a...@svilendobrev.com wrote: object-query or plain query? - objects are .. whatever class it is; print the i.__dict__ or str(i) or whatever - plain-sql-query ones are RowProxy, they have i.keys() i.items() i.values() i.__dict__ it is... Thanks a lot... Lucas On Tuesday 10 February 2009 21:27:09 Lukasz Szybalski wrote: Hello, Could somebody tell me how can I print the object data in my result set without knowing the column names? myresult=session.query(...).all() for i in myresult: print I need to debug some data and its hard to print the object keys and values (column names and its values) . i.keys() ? i.items()? some dictionary like functions would be nice. -- How to create python package? http://lucasmanual.com/mywiki/PythonPaste Bazaar and Launchpad http://lucasmanual.com/mywiki/Bazaar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: resultset print keys values
dir(instance) is preferable to __dict__.keys() - the latter will not give you deferred attributes, unloaded collections, or the expired version of each of those. dir() respects descriptors basically. Lukasz Szybalski wrote: Hello, Could somebody tell me how can I print the object data in my result set without knowing the column names? myresult=session.query(...).all() for i in myresult: print I need to debug some data and its hard to print the object keys and values (column names and its values) . i.keys() ? i.items()? some dictionary like functions would be nice. sqlalchemy.__version__ '0.5.0rc1' Thanks, Lucas -- How to create python package? http://lucasmanual.com/mywiki/PythonPaste Bazaar and Launchpad http://lucasmanual.com/mywiki/Bazaar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: resultset print keys values
On Tue, Feb 10, 2009 at 1:52 PM, Michael Bayer mike...@zzzcomputing.com wrote: dir(instance) is preferable to __dict__.keys() - the latter will not give you deferred attributes, unloaded collections, or the expired version of each of those. dir() respects descriptors basically. but then dir() includes stuff like: '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_sa_class_manager', '_sa_instance_state'] Which need to be filtered. Then for the remaining items need to loop through to get the value?! I figured there was a uniform function that would return dictionary of key/value pairs that is available on all the possible return objects. __dict__ is good enough for visual inspection for now. Thanks, Lucas Lukasz Szybalski wrote: Hello, Could somebody tell me how can I print the object data in my result set without knowing the column names? myresult=session.query(...).all() for i in myresult: print I need to debug some data and its hard to print the object keys and values (column names and its values) . i.keys() ? i.items()? some dictionary like functions would be nice. sqlalchemy.__version__ '0.5.0rc1' Thanks, Lucas -- How to create python package? http://lucasmanual.com/mywiki/PythonPaste Bazaar and Launchpad http://lucasmanual.com/mywiki/Bazaar -- How to create python package? http://lucasmanual.com/mywiki/PythonPaste Bazaar and Launchpad http://lucasmanual.com/mywiki/Bazaar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: resultset print keys values
Hi, On Tue, Feb 10, 2009 at 3:18 PM, Lukasz Szybalski szybal...@gmail.comwrote: On Tue, Feb 10, 2009 at 1:52 PM, Michael Bayer mike...@zzzcomputing.com wrote: dir(instance) is preferable to __dict__.keys() - the latter will not give you deferred attributes, unloaded collections, or the expired version of each of those. dir() respects descriptors basically. but then dir() includes stuff like: '__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', '_sa_class_manager', '_sa_instance_state'] Which need to be filtered. Then for the remaining items need to loop through to get the value?! I figured there was a uniform function that would return dictionary of key/value pairs that is available on all the possible return objects. __dict__ is good enough for visual inspection for now. Wouldn't this do what you need: http://www.sqlalchemy.org/trac/wiki/FAQ#Whatsthebestwaytofigureoutwhichattributesarecolumnsgivenaclass -- Michael Trier http://blog.michaeltrier.com/ http://thisweekindjango.com/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---