Thread: [SQLObject] List columns in a class
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Julien S. <nep...@gm...> - 2010-07-22 00:04:49
|
Hello everyone, Sorry if the question was already asked, i searched but i didn't find anything. I want to know how can i do to have a list of columns in my table with my object. I explain, i have my object like this : <Rights 1 user_view=True user_create=True user_modify=False user_delete=False groups_view=True groups_create=False groups_modify=True groups_delete=False modules_execute=True modules_install=False modules_delete=True graphs_view=True graphs_create=False graphs_modify=True graphs_delete=True alerts_view=True alerts_create=True alerts_modify=True alerts_delete=True hosts_view=False hosts_create=True hosts_modify=False hosts_delete=True> What i want to do is something like this : for columns in table: print columns.name I defined my class like this : Class Rights(SQLObject): user_view = BoolCol ... Can you help me ? Thanks a lot ! |
From: Oleg B. <ph...@ph...> - 2010-07-22 06:02:24
|
On Thu, Jul 22, 2010 at 02:04:21AM +0200, Julien Syx wrote: > What i want to do is something like this : > > for columns in table: > print columns.name > > I defined my class like this : > Class Rights(SQLObject): > user_view = BoolCol > ... print Rights.sqlmeta.columnList print Rights.sqlmeta.columns print Rights.sqlmeta.joins print Rights.sqlmeta.indexes See the class sqlmeta in main.py. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Julien S. <nep...@gm...> - 2010-07-22 08:47:33
|
Shame on me, it was too late, i was tired :p That's do the trick. Thanks Oleg ;-) On Thu, Jul 22, 2010 at 8:02 AM, Oleg Broytman <ph...@ph...> wrote: > On Thu, Jul 22, 2010 at 02:04:21AM +0200, Julien Syx wrote: > > What i want to do is something like this : > > > > for columns in table: > > print columns.name > > > > I defined my class like this : > > Class Rights(SQLObject): > > user_view = BoolCol > > ... > > print Rights.sqlmeta.columnList > print Rights.sqlmeta.columns > print Rights.sqlmeta.joins > print Rights.sqlmeta.indexes > > See the class sqlmeta in main.py. > > Oleg. > -- > Oleg Broytman http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Julien S. <nep...@gm...> - 2010-07-22 12:50:08
|
It's okay with the field name. I would like to have field/value. It's okay to have field with : for col in rights.sqlmeta.columnList: print "column:"+str(col.name)+ " | value:"+str(col) It returns to me : column:hosts_delete | value:<SOBoolCol hosts_delete> I tried col.value, but no way. Have you an idea ? I didn't see docs nor exemple on web. Thanks a lot ! On Thu, Jul 22, 2010 at 10:47 AM, Julien Syx <nep...@gm...>wrote: > Shame on me, it was too late, i was tired :p > > That's do the trick. > > Thanks Oleg ;-) > > On Thu, Jul 22, 2010 at 8:02 AM, Oleg Broytman <ph...@ph...> wrote: > >> On Thu, Jul 22, 2010 at 02:04:21AM +0200, Julien Syx wrote: >> > What i want to do is something like this : >> > >> > for columns in table: >> > print columns.name >> > >> > I defined my class like this : >> > Class Rights(SQLObject): >> > user_view = BoolCol >> > ... >> >> print Rights.sqlmeta.columnList >> print Rights.sqlmeta.columns >> print Rights.sqlmeta.joins >> print Rights.sqlmeta.indexes >> >> See the class sqlmeta in main.py. >> >> Oleg. >> -- >> Oleg Broytman http://phd.pp.ru/ ph...@ph... >> Programmers don't die, they just GOSUB without RETURN. >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Sprint >> What will you do first with EVO, the first 4G phone? >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first >> _______________________________________________ >> sqlobject-discuss mailing list >> sql...@li... >> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss >> > > |
From: Oleg B. <ph...@ph...> - 2010-07-22 13:46:14
|
On Thu, Jul 22, 2010 at 02:49:39PM +0200, Julien Syx wrote: > It's okay with the field name. > > I would like to have field/value. > It's okay to have field with : > > for col in rights.sqlmeta.columnList: > print "column:"+str(col.name)+ " | value:"+str(col) > > It returns to me : column:hosts_delete | value:<SOBoolCol hosts_delete> > > I tried col.value, but no way. > Have you an idea ? I didn't see docs nor exemple on web. If 'rights' is a row from the Rights table then rights.hosts_delete is the value of the column. To get the value by name use getattr(): for col in rights.sqlmeta.columnList: print "column:"+str(col.name)+ " | value:"+str(getattr(rights, col.name)) Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |