- 基本命令
root@8a5fa5a8f6b8:/usr/bin# /usr/bin/mongo
show dbs;
use db_sys;
show tables;
db.users.find(); # select * from users ;
https://www.cnblogs.com/TankMa/archive/2011/06/08/2074947.html
- python下使用
myclient = pymongo.MongoClient('mongodb://x.x.x.x:27017/')
dblist = myclient.list_database_names()
# print(dblist)
db_sys = myclient['sys']
# print(db_sys)
model_info = db_sys['users'].find_one()
# print(model_info)
model_info = db_sysdog['users'].find() # 返回的是<class 'pymongo.cursor.Cursor'>
print(dir(model_info)) # 有__next__,__iter__方法
for i in model_info:
print(i)
db_sys.list_collection_names() #show tables;