문제

I have a Text model;

class Text(db.Document):
    siphash_value = db.LongField()

Then I use siphash lib for create a hash.(https://github.com/majek/pysiphash)

This lib converts string to long value like 12398370950267227270L

If I try save document to my db;

Text(siphash_value=12398370950267227270L).save()

I get this error:

OverflowError: MongoDB can only handle up to 8-byte ints
도움이 되었습니까?

해결책

MongoDB only supports 64 bit integers (bson.spec) so pymongo can't convert the Long hence the error.

다른 팁

Could you tell us WHY it is working now? The new library is returning a non long field? (I can not comment your own answer because I have less than 50 reputation, sorry all).

I tried to replace LongField by FloatField and it worked. And actually it has the same result. Just had a different notation (1.2398370950267228e+19).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top