Skip to content

Commit 12a0920

Browse files
authored
Merge pull request #6 from Sponsorlytix-Ltd/chore/mongo_client
Chore/mongo client
2 parents 7be1a1a + fd52e14 commit 12a0920

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
setup(
1616
name='sponsorlytix_api_utils',
1717
description='Sponsorlytix code utils',
18-
version='1.1',
18+
version='1.2',
1919
author='Sponsorlytix Team',
2020
install_requires=requirements,
2121
setup_requires=['pytest-runner'],
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import os
2-
31
from pymongo import MongoClient
42

53

64
class SponsorlytixMongoClient:
75

8-
def __init__(self, mongodb_config, db_name='sponsorlytix'):
9-
host, port = mongodb_config.get('host'), mongodb_config.get('port')
6+
def __init__(self, host, port, db_name):
107
client = MongoClient(host, port)
11-
self.client = client[db_name]
8+
self.client = client.get_database(db_name)
129

1310
def get_collection(self, collection_name):
14-
return self.client[collection_name]
11+
return self.client.get_collection(collection_name)
1512

1613
@classmethod
17-
def get_client(cls, db_name='sponsorlytix'):
18-
mongo_url = os.environ.get('MONGO_URL')
19-
mongo_conn = MongoClient(mongo_url, 27017)
20-
return mongo_conn[db_name]
14+
def get_client(cls, host, port, db_name):
15+
client = MongoClient(host, port)
16+
return client.get_database(db_name)

0 commit comments

Comments
 (0)