Data modeling

api.mongodb.com

{
	"manufacturer" : "Tesla Motors",
	"class" : "full-size",
	"body style" : "5-door liftback"
}

production felds

{
	"production" : [2012, 2013],
	"model years" : [2013],
	"layout" : ["Rear-motor", "rear-wheel drive"]
}

designer

{
	"designer" : {
		"firstname" : "Franz",
		"surname" : "von Holzhusen"
	}
}
{
	"assembly" : [
		{
			"country" : "United States",
			"city" : "Fremount",
			"state" : "California"
		},
		{
			"country" : "The Netherlands",
			"city" : "Tilburg"
		}
	]
}
{
	"manufacturer" : "Tesla Motors",
	"class" : "full-size",
	"body style" : "5-door liftback",
	"production" : [2012, 2013],
	"model years" : [2013],
	"layout" : ["Rear-motor", "rear-wheel drive"],
	"designer" : {
		"firstname" ; "Franz",
		"surname" : "von Holzhusen"
	},
	"assembly" : [
		{
			"country" : "United States",
			"city" : "Fremont",
			"state" : "California"
		},]
}
def add_city(db):
	db.cities.insert({"name": "Chicago"})

def get_city(db):
	return db.cities.find_one()

def get_db():
	from pymongo import MongoClient
	client = MongoClient('localhost:27017')
	db = client.examples
	return db

if __name__ == "__main__":
	add_city(db)
	print get_city(db)