python3 : เชื่อมต่อ mongoDb

step 1 ติดตั้งด้วยคำสั่ง
py -m pip install pymongo



step2 ลองรัน Code ดังนี้ (ใช้ฐานข้อมูลจากตัวอย่างก่อนหน้านี้)
from pymongo import MongoClient
# pprint library is used to make the output look more pretty
from pprint import pprint
# connect to MongoDB, change the << MONGODB URL >> to reflect your own connection string
client = MongoClient('mongodb://localhost:27017')
db=client.NetFlick
# Issue the serverStatus command and print the results
#serverStatusResult=db.command("serverStatus")
result = db.movies.find()
#print(serverStatusResult)

for r in result:
print (r)

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

CASIO fx-5800P : การ mod ด้วยเครื่องคิดเลข

sgsBB(SGS-Score Inserter) : โปรแกรมช่วยกรอกผลคะแนนจาก bookmark51 ใส่ระบบ SGS ของ สพฐ.

springMVC : เชื่อมต่อฐานข้อมูล mySQL ด้วย JDBC-Template