+ All Categories
Home > Documents > PyCon 2010 Poster on MongoDB

PyCon 2010 Poster on MongoDB

Date post: 18-Nov-2014
Category:
Upload: mdirolf
View: 117 times
Download: 2 times
Share this document with a friend
Description:
Poster session on MongoDB from PyCon 2010.
Popular Tags:
1
Replication Auto-sharding open-source, high-performance, schema-free, document-oriented database “One size fits all” no longer Scaling out Side effect No joins Light transactional semantics New data models Improved developer experience Documents and BSON {“hello”: “world”} '\x16\x00\x00\x00\x02hello \x00\x06\x00\x00\x00world\x00\x00' Schema-free collections {“hello”: “world”, “foo”: [{“bar”: 1}]} http://www.mongodb.org http://api.mongodb.org/python @mongodb @mdirolf Working with PyMongo master slave slave slave slave master / slave replica sets master slave master slave master master slave master mongod mongod mongod mongod mongod mongod mongod mongod mongod mongos mongos client shards config servers Focus on performance depth of functionality scalability & performance memcached key/value mongodb RDBMS Next gen OLAP (vertica, aster, greenplum) Non-relational operational stores (“NoSQL”) RDBMS (oracle, mysql) >>> import datetime >>> import pymongo >>> connection = pymongo.Connection() >>> db = connection.test >>> # Inserting documents ... >>> db.posts.insert({"author": "mike", ... "date": datetime.datetime.utcnow(), ... "text": "my blog post...", ... "tags":["mongodb", "python"]}) ObjectId('4b743bdde6fb1b969b000000') >>> # Atomic update modifiers ... >>> comment = {"author": "eliot", ... "date": datetime.datetime.utcnow(), ... "text": "great post!"} >>> db.posts.update({"_id": pymongo.objectid.ObjectId('4b743bdde6fb1b969b000000')}, ... {"$push":{"comments": comment}}) >>> # Dynamic queries ... >>> db.posts.find_one() {u'tags':[u'mongodb', u'python'], u'text': u'my blog post...', u'author': u'mike', u'comments': [{u'date': datetime.datetime(2010, 2, 11, 17, 19, 10, 64000), u'text': u'great post!', u'author': u'eliot'}], u'date': datetime.datetime(2010, 2, 11, 17, 18, 21, 716000), u'_id': ObjectId('4b743bdde6fb1b969b000000')} >>> db.posts.find({"author": "mike"}) <pymongo.cursor.Cursor object at 0x100529ad0> >>> for post in db.posts.find({"author": "mike"}): ... post['text'] ... u'my blog post...' >>> # Advanced query operators ... >>> db.posts.find().sort("date", pymongo.DESCENDING).limit(10) <pymongo.cursor.Cursor object at 0x100529bd0> >>> last_week = datetime.datetime.utcnow() + datetime.timedelta(days=7) >>> db.posts.find({"date":{"$gt": last_week}}) <pymongo.cursor.Cursor object at 0x100529a10> >>> # Reaching inside embedded lists and documents ... >>> db.posts.find({"tags": "mongodb"}) <pymongo.cursor.Cursor object at 0x100529a50> >>> db.posts.create_index("tags") u'tags_1' >>> db.posts.create_index("comments.author") u'comments.author_1'
Transcript
Page 1: PyCon 2010 Poster on MongoDB

Replication

Auto-sharding

open-source, high-performance, schema-free, document-oriented

database

“One size fits all” no longer

Scaling out

Side effect

No joins

Light transactional semantics

New data models

Improved developer experience

Documents and BSON

{“hello”:  “world”}

'\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00'

Schema-free collections

{“hello”:  “world”,  “foo”:  [{“bar”:  1}]} http://www.mongodb.org

http://api.mongodb.org/python

@mongodb@mdirolf

Working with PyMongo

master

slave slaveslave

slave

master / slave replica sets

master slave

master slave

master master

slave master

mongod

mongod

mongod

mongod

mongod

mongod

mongod

mongod

mongodmongos mongos

client

shards

configservers

Focus on performance

depth of functionality

scal

abil

ity

& p

erfo

rman

ce •memcached

•key/value •mongodb

•RDBMS

Next gen OLAP(vertica, aster, greenplum)

Non-relational

operational stores(“NoSQL”)

RDBMS(oracle, mysql)

>>>  import  datetime

>>>  import  pymongo

>>>  connection  =  pymongo.Connection()>>>  db  =  connection.test

>>>  #  Inserting  documents...>>>  db.posts.insert({"author":  "mike",...                                    "date":  datetime.datetime.utcnow(),...                                    "text":  "my  blog  post...",...                                    "tags":  ["mongodb",  "python"]})ObjectId('4b743bdde6fb1b969b000000')

>>>  #  Atomic  update  modifiers...>>>  comment  =  {"author":  "eliot",...                        "date":  datetime.datetime.utcnow(),...                        "text":  "great  post!"}>>>  db.posts.update({"_id":  pymongo.objectid.ObjectId('4b743bdde6fb1b969b000000')},...                                  {"$push":  {"comments":  comment}})

>>>  #  Dynamic  queries...>>>  db.posts.find_one(){u'tags':  [u'mongodb',  u'python'],  u'text':  u'my  blog  post...',  u'author':  u'mike',  u'comments':  [{u'date':  datetime.datetime(2010,  2,  11,  17,  19,  10,  64000),                                                u'text':  u'great  post!',                                                  u'author':  u'eliot'}],  u'date':  datetime.datetime(2010,  2,  11,  17,  18,  21,  716000),  u'_id':  ObjectId('4b743bdde6fb1b969b000000')}>>>  db.posts.find({"author":  "mike"})<pymongo.cursor.Cursor  object  at  0x100529ad0>>>>  for  post  in  db.posts.find({"author":  "mike"}):...      post['text']...  u'my  blog  post...'

>>>  #  Advanced  query  operators...>>>  db.posts.find().sort("date",  pymongo.DESCENDING).limit(10)<pymongo.cursor.Cursor  object  at  0x100529bd0>>>>  last_week  =  datetime.datetime.utcnow()  +  datetime.timedelta(days=-­‐7)>>>  db.posts.find({"date":  {"$gt":  last_week}})<pymongo.cursor.Cursor  object  at  0x100529a10>

>>>  #  Reaching  inside  embedded  lists  and  documents...>>>  db.posts.find({"tags":  "mongodb"})<pymongo.cursor.Cursor  object  at  0x100529a50>>>>  db.posts.create_index("tags")u'tags_1'>>>  db.posts.create_index("comments.author")u'comments.author_1'

Recommended