Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

using ReadPreference instead of slave_ok for pymongo 2.x

  • Loading branch information...
commit 1a06d906d134b8060f3f9561a5a9bbccdfca94b3 1 parent 3a0274a
@bdarfler bdarfler authored
Showing with 6 additions and 3 deletions.
  1. +2 −1  mongo_collcount
  2. +2 −1  mongo_collsize
  3. +2 −1  mongo_indexsize
View
3  mongo_collcount
@@ -29,6 +29,7 @@
from pymongo import Connection
+from pymongo import ReadPreference
settings_host = '127.0.0.1'
settings_port = 27017
@@ -36,7 +37,7 @@ settings_db = 'mydb'
def getCollstats():
- con = Connection(settings_host, int(settings_port), slave_okay=True)
+ con = Connection(settings_host, int(settings_port), read_preference=ReadPreference.SECONDARY)
db = con[settings_db]
for coll in db.collection_names():
View
3  mongo_collsize
@@ -29,6 +29,7 @@
from pymongo import Connection
+from pymongo import ReadPreference
settings_host = '127.0.0.1'
settings_port = 27017
@@ -38,7 +39,7 @@ settings_fields = {'totalIndexSize': 'index', 'storageSize': 'storage', 'size':
def getCollstats():
- con = Connection(settings_host, int(settings_port), slave_okay=True)
+ con = Connection(settings_host, int(settings_port), read_preference=ReadPreference.SECONDARY)
db = con[settings_db]
stats = db.command("collstats", settings_collection)
View
3  mongo_indexsize
@@ -29,6 +29,7 @@
from pymongo import Connection
+from pymongo import ReadPreference
settings_host = '127.0.0.1'
settings_port = 27017
@@ -36,7 +37,7 @@ settings_db = 'mydb'
def getCollstats():
- con = Connection(settings_host, int(settings_port), slave_okay=True)
+ con = Connection(settings_host, int(settings_port), read_preference=ReadPreference.SECONDARY)
db = con[settings_db]
for coll in db.collection_names():
Please sign in to comment.
Something went wrong with that request. Please try again.