Python 2.7スクリプトのファイルからコレクションを読み込んでいますが、サーバーCLIで直接実行するのではなく、スクリプトからsommeコマンドを実行したいと思います。
私のコードは次のようなものです:
import pymongo
...
def function(database)
client = MongoClient()
db=client[database]
... (populating the collection with documents, that works well) ...
db.getSiblingDB('admin').runCommand({setParameter:1, failIndexKeyTooLoong: false})
db.Collection.createIndex({"key":1})
...
最後の2つのコマンドを機能させることはできません...それも可能ですか?
ご協力いただきありがとうございます。
インデックスを作成する方法は、「create_index」、http: //api.mongodb.com/python/current/tutorial.html#indexingです。
コマンドも制限されていますが、実行方法は次のとおりです。http://api.mongodb.com/python/current/api/pymongo/database.html?highlight = command #pymongo.database.Database.command
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加