I think you can already db.table.insert(**dict(....))
Are you asking for something different? On Saturday, 12 May 2012 05:25:02 UTC-5, Francisco Costa wrote: > > It works Massimo! > In MongoDb is also common to insert dicts, can we also have that? > > At the moment it only saves in the string format (check player Field) > { "_id" : ObjectId("4fae3839b34f4brf5a000031"), "city" : "Madrid", "club" > : "Real Madrid", *"player" : "{'n_goals': 43, 'name': 'Ronaldo'}"* } > > > > On Friday, May 11, 2012 9:16:58 PM UTC+1, Massimo Di Pierro wrote: >> >> One more try please. >> >> On Friday, 11 May 2012 06:04:52 UTC-5, Francisco Costa wrote: >>> >>> Thanks Massimo. Please let me know if you need more help in debugging it >>> >>> On Friday, May 11, 2012 12:40:35 AM UTC+1, Massimo Di Pierro wrote: >>>> >>>> Now I understand better where all these problems come from. I shall fix >>>> it tonight. >>>> >>>> On Thursday, 10 May 2012 18:02:24 UTC-5, Francisco Costa wrote: >>>>> >>>>> i didn't understand your question.. >>>>> This is the complete code >>>>> >>>>> import sys >>>>> import time >>>>> from gluon.dal import DAL, Field >>>>> mongo = DAL('mongodb://localhost:27017/sapo') >>>>> mongo.define_table('user', >>>>> Field('name', 'text'), >>>>> Field('age', 'integer'), >>>>> Field('city', 'string') >>>>> ) >>>>> >>>>> def insert_users(): >>>>> mongo.user.insert(name='John', age=66, city='Toronto') >>>>> mongo.user.insert(name='Mark', age=43, city='Boston') >>>>> mongo.user.insert(name='Tom', age=43, city='Detroit') >>>>> mongo.user.insert(name='Jim', age=18, city='Detroit') >>>>> mongo.user.insert(name='Jack', age=18) >>>>> mongo.user.insert(name='Eric', city='Boston') >>>>> return 'users in database' >>>>> >>>>> def find_users(): >>>>> users = mongo(mongo.user.age==18).select() >>>>> return dict(users=users) >>>>> >>>>>