1、MongoClient()函数

In [8]: import pymongo

In [9]: con = pymongo.MongoClient('localhost')   #建立连接

In [10]: db = con['测试']    #创建名为‘测试’的数据库

In [11]: db['表1'].insert({'1':'吃饭','two':'睡觉'})   #创建‘表1’并且插入数据
C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Scripts\ipython:1: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead.
Out[11]: ObjectId('597ade7c04ec7e19a0f877e2')

 

posted on 2017-07-28 15:03  漏三刀  阅读(142)  评论(0编辑  收藏  举报