On Thursday, October 20, 2016 at 9:11:52 AM UTC-4, Scott Hunter wrote:
>
> Your fields are of type string (the default); so either make string
> representations of your lists or declare the fields as lists of strings.
>
> Or, if you are trying to use this data to define *multiple* records,
> something like this might do what you want:
>
> for i in xrange(3):
> db.color.insert( blue=COLORED_THINGS['blue'][i],
> yellow=COLORED_THINGS['yellow'][i], red=COLORED_THINGS['red'][i] )
>
If this is indeed what you want, then it would be better if you could
structure the data as a list of dictionaries (instead of a dictionary with
lists as its values):
COLORED_THINGS = [
{'blue': 'sky', 'yellow': 'sun', 'red': 'blood'},
{'blue': 'jeans', 'yellow': 'banana', 'red': 'tomato'}
]
And use .bulk_insert to create the records:
db.color.bulk_insert(COLORED_THINGS)
Anthony
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.