In [1]:
import pymongo

In [2]:
client = pymongo.MongoClient()

In [3]:
db = client['olx']

In [4]:
collection = db['cars']

In [5]:
import datetime as dt

In [6]:
car = {'title': 'Gol Completo', 'ports': 4, 'year': '2015/2016', 'date': dt.datetime.now()}

In [7]:
car


Out[7]:
{'date': datetime.datetime(2017, 5, 1, 15, 48, 24, 195224),
 'ports': 4,
 'title': 'Gol Completo',
 'year': '2015/2016'}

In [8]:
collection.insert_one(car)


Out[8]:
<pymongo.results.InsertOneResult at 0x10880aee8>

In [9]:
result = collection.find_one({'title': 'Gol Completo'})

In [ ]: