Skip to content

Commit ac840fc

Browse files
author
tuntun
committed
mongodb连接(带数据库密码)
1 parent 5277e2e commit ac840fc

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

testmongo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
from pymongo import MongoClient
3+
import datetime
4+
5+
client = MongoClient('mongodb://tanteng:123456@localhost:27017/')
6+
db = client.js_send_excel
7+
8+
post = {"author": "Xiaofeng", "text": "My first blog post!",
9+
"tags": ["mongodb", "python", "pymongo"],}
10+
11+
posts = db.posts
12+
post_id = posts.insert_one(post).inserted_id
13+
print(post_id)

0 commit comments

Comments
 (0)