bson

Convert bytes in string using python

Convert bytes in string using python Question: I have bson file, and i dont know what have inside of the document. I see the data type, and conclude the type of data is bytes. So, for undertsand the content the file, i need to save in readable formart. So, the firt step was convert my …

Total answers: 1

AttributeError: 'dict' object has no attribute 'distinct'

AttributeError: 'dict' object has no attribute 'distinct' Question: I have a bson file, and i dont know what have inside of the file. So, a read the file. And now, i still trying to found the value of each key, but not is easy. Because, i receive the messange: AttributeError: ‘dict’ object has no attribute …

Total answers: 1

What can I do to output in MongoDB with $inc from always being decimal with 2 point accuracy? (rounding output)

What can I do to output in MongoDB with $inc from always being decimal with 2 point accuracy? (rounding output) Question: So I’m using MongoDB 6.0 (and motor driver in python) and for example I have a code like that: money = 4.92 from_snowflake = "19251" await db["bank"].update_one({"snowflake": str(from_snowflake)}, {"$inc": {"balance": -float(money)}}) and assuming the …

Total answers: 1

May I use bson.objectid.ObjectId as (primary key) id in sql?

May I use bson.objectid.ObjectId as (primary key) id in sql? Question: I am thinking if I don’t use auto id as primary id in mysql but use other method to implement, may I replace auto id from bson.objectid.ObjectId in mysql? According to ObjectId description, it’s composed of: a 4-byte value representing the seconds since the …

Total answers: 1

Bottle framework: how to return datetime in JSON response

Bottle framework: how to return datetime in JSON response Question: When I try to return JSON containing datetime value, I’m getting File “/usr/lib/python2.7/json/encoder.py”, line 178, in default raise TypeError(repr(o) + ” is not JSON serializable”) TypeError: datetime.datetime(2014, 2, 1, 0, 0) is not JSON serializable Which is normal. Is there an easy way to add …

Total answers: 2