From 10c8465e4ff3914b1d7f444b743ff1d3c4911d98 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Thu, 3 May 2012 21:49:52 +0200 Subject: Distant MongoDB connection working (tested with AlwaysData). --- source/mongodb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/mongodb.py') diff --git a/source/mongodb.py b/source/mongodb.py index 727d8183..fd605465 100644 --- a/source/mongodb.py +++ b/source/mongodb.py @@ -15,12 +15,14 @@ from operator import itemgetter, attrgetter class Articles(object): """ """ - def __init__(self, url='localhost', port=27017): + def __init__(self, url='localhost', port=27017, db_name="pyaggr3g470r", user="", password=""): """ Instantiates the connection. """ self.connection = pymongo.connection.Connection(url, port) - self.db = self.connection.pyaggr3g470r + self.db = pymongo.database.Database(self.connection, db_name) + self.db.authenticate(user, password) + self.db = self.connection[db_name] def add_collection(self, new_collection): """ -- cgit