1
mongodb文件中的整數值保存32int。 我想在mongodb中保存64位值。使用PyMongo創建NumberLong整數
代碼是在這裏:
import time
import datetime
from pymongo import MongoClient
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.test_database
data = {}
data['num'] = 100
data['createAt'] = datetime.datetime.now()
curTime = datetime.datetime.now()
curTime = int(time.mktime(curTime.timetuple()))
data['time'] = curTime
db.test.insert(data)
結果:
{
"_id" : ObjectId("583420ce7e60a74345c97624"),
"num" : NumberInt(100),
"createAt" : ISODate("2016-11-22T15:41:18.773+0000"),
"time" : NumberInt(1479811278)
}
通緝的結果是:
{
"_id" : ObjectId("583420ce7e60a74345c97624"),
"num" : NumberLong(100),
"createAt" : ISODate("2016-11-22T15:41:18.773+0000"),
"time" : NumberLong(1479811278)
}
其存儲在NumberInt而非NumberLong