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