I figured out what the problem was but forgot to come back to the
forum.
The problem was that the keys of the dictionary was encoded as
unicode, for example u'keyname'. It was in unicode because the dict is
loaded from json. Specify their encoding as UTF-8 with following
routine, solved the problem.
def loadFromJson(jsonData):
data=json.loads(jsonData, encoding='utf-8')
#encode the keys as UTF-8
return dict((k.encode('utf-8'),v) for (k,v) in data.items())
I hope this solution could help others with similar problems.
On 9월9일, 오후10시26분, Massimo Di Pierro <[email protected]>
wrote:
> yes, puzzling. Can we see a concerete example?
>
> On Sep 8, 10:21 pm,seongjoo<[email protected]> wrote:
>
>
>
> > Hello,
>
> > It looks like:
>
> > dict = {'email':''[email protected]', 'name':'dude', 'accesskey': [some
> > hash string]}
>
> > I tried insertion with other table and other dict and it worked. So I
> > figured that, as you properly guessed, it must be the problem relating
> > the dict that I am trying to insert.
>
> > But what puzzles me is that if the dict is the source of the problem,
> > why wouldn't db.table.bulk_insert([dict]) fail?
>
> > On 9월8일, 오후11시20분, Bruno Rocha <[email protected]> wrote:
>
> > > How your dict looks like?
>
> > >http://zerp.ly/rochacbruno
> > > Em 08/09/2011 11:10, "seongjoo" <[email protected]> escreveu:
>
> > > > Hello,
>
> > > > I am using web2py 1.98.2.
>
> > > > The problem is that below instruction fails with error message:
> > > > "TypeError: insert() keywords must be strings"
>
> > > > db.table.insert(**dictionary)
>
> > > > While db(query).update(**dictionary) works find.
>
> > > > For now, I have to use as a workaround as below.
>
> > > > bulk_insert( [dictionary] )
>
> > > > What would be wrong?- 원본 텍스트 숨기기 -
>
> - 원본 텍스트 보기 -