oot@ubuntu:/home/lee/mongodb-linux-i686-1.6.4/bin# python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from_pymongo_import Connection
File "<stdin>", line 1
from_pymongo_import Connection
^
SyntaxError: invalid syntax
>>> improt pymongo
File "<stdin>", line 1
improt pymongo
^
SyntaxError: invalid syntax
>>> import pymongo
>>> from pymongo import Connection
>>> conection=Connection()
>>> connection=Connection('localhost',1234)
>>> db=connection['test']
>>> collection=db['test']
>>> import datetime
>>> post ={"author": "mike",
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from_pymongo_import Connection
File "<stdin>", line 1
from_pymongo_import Connection
^
SyntaxError: invalid syntax
>>> improt pymongo
File "<stdin>", line 1
improt pymongo
^
SyntaxError: invalid syntax
>>> import pymongo
>>> from pymongo import Connection
>>> conection=Connection()
>>> connection=Connection('localhost',1234)
>>> db=connection['test']
>>> collection=db['test']
>>> import datetime
>>> post ={"author": "mike",
"text" : "my first blo post!",
"tags" :["mongodb","python","pymongo"],
"date" :datetime.datetime.utcnow()}
>>> posts=db.posts
>>> posts.insert(post)
ObjectId('4dad537e1d41c80d2f000000')
>>> db.collection_names()
[u'posts', u'system.indexes']
>>> posts.find_one()
{u'date': datetime.datetime(2011, 4, 19, 9, 18, 34, 441000), u'text': u'my first blo post!', u'_id': ObjectId('4dad537e1d41c80d2f000000'), u'author': u'mike', u'tags': [u'mongodb', u'python', u'pymongo']}
can kao lian jie
http://api.mongodb.org/python/1.10.1%2b/tutorial.html