-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinsert.py
More file actions
30 lines (29 loc) · 645 Bytes
/
insert.py
File metadata and controls
30 lines (29 loc) · 645 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
###
#
# @Name : MongoDbPython/insert.py
# @Version : 1.0
# @Programmer : Max
# @Date : 2018-12
# @Released under : https://github.com/BaseMax/MongoDbPython/blob/master/LICENSE
# @Repository : https://github.com/BaseMax/MongoDbPython
#
###
# Some useful libraries
import pymongo
import json
import os
import sys
client = pymongo.MongoClient("mongodb://localhost:27017/")
#dblist = myclient.list_database_names()
db_name = "name"
db = client[db_name]
#Get `post` table
table_post = db["post"]
#Sample Value
object_post = {
"title": "Title",
"text": "Text",
}
#Insert one row
request = table_post.insert_one(object_post)