this test worked (yeah, i asked the question too hastily again ;) )

for item in self.db[table].fields:
    if isinstance(self.db[table][item].type,str) \
            and self.db[table][item].type=='string':
        print 'field is string: {0}'.format(self.db[table][item])


returned:

field is string: cumulativeProperties.uuid
field is string: cumulativeProperties.name
field is string: cumulativeProperties.value
field is string: cumulativeProperties.tag
field is string: cumulativeProperties.cmdname


thanks,
Mart :)


On Jul 6, 12:59 pm, mart <msenecal...@gmail.com> wrote:
> almost :) i'm looking to guess the field types. for example, at the
> cmd line i can use a quick and dirty helper like this:
>
> -table myTable fields=id,name,value
>
> this displays a nice ascii table but, the fields are comma delimited
> so if the returned field is a list (also comma delimited), the table
> isn't very pretty anymore (because it separates the field items with
> commas :))
>
> so if I can get the script to guess the field type, i can replace the
> comma with a line break (which would just extend the table field in
> height)
>
> thanks,
> Mart :)
>
> On Jul 6, 12:48 pm, Anthony <abasta...@gmail.com> wrote:
>
>
>
>
>
>
>
> > db.tables is a list of the names of the tables in db, and
> > db.tablename.fields is a list of the names of the fields in db.tablename. Is
> > that what you're looking for?
>
> > Anthony
>
> > On Wednesday, July 6, 2011 12:27:09 PM UTC-4, mart wrote:
> > > hi,
>
> > > question:
>
> > > how could I guess the field in something like an interactive shell?
>
> > > i assume, I have to specify db.tableName.filedName?
>
> > > is there something like db.myTable.myField.type?
>
> > > thanks,
> > > Mart :)
>
> > > On Jul 4, 12:11 pm, mart <msene...@gmail.com> wrote:
> > > > ah ha! thank you very much!!!!! :)
>
> > > > On Jul 4, 11:46 am, Massimo Di Pierro <massimo....@gmail.com>
> > > > wrote:
>
> > > > > f = Field('myString')
>
> > > > > print f.type
> > > > > if isinstance(f.type,str) and f.type=='string': ..
> > > > > if isinstance(f.type,str) and f.type=='text': ..
> > > > > if isinstance(f.type,str) and f.type=='upload': ..
> > > > > if isinstance(f.type,str) and f.type=='blob': ..
> > > > > ..
> > > > > if not isinstance(f.type,str): # custom field probably
>
> > > > > On Jul 4, 10:17 am, mart <msene...@gmail.com> wrote:
>
> > > > > > woops, sorry....
>
> > > > > > so something like:
>
> > > > > > if isinstance(Field,list): blala
> > > > > > elif isinstance(Field,str): blala
> > > > > > else:blabla
>
> > > > > > thanks,
> > > > > > Mart :)
>
> > > > > > On Jul 4, 11:15 am, mart <msene...@gmail.com> wrote:
>
> > > > > > > Can dal guess field type even if not explicit?
>
> > > > > > > I.e. if I have a Field like Field('myString') but a script ends up
> > > > > > > inserting something that looks like a list, how can I have a
> > > default
> > > > > > > check?
>
> > > > > > > something like:

Reply via email to