File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change 15
15
setup (
16
16
name = 'sponsorlytix_api_utils' ,
17
17
description = 'Sponsorlytix code utils' ,
18
- version = '1.1 ' ,
18
+ version = '1.2 ' ,
19
19
author = 'Sponsorlytix Team' ,
20
20
install_requires = requirements ,
21
21
setup_requires = ['pytest-runner' ],
Original file line number Diff line number Diff line change 1
- import os
2
-
3
1
from pymongo import MongoClient
4
2
5
3
6
4
class SponsorlytixMongoClient :
7
5
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 ):
10
7
client = MongoClient (host , port )
11
- self .client = client [ db_name ]
8
+ self .client = client . get_database ( db_name )
12
9
13
10
def get_collection (self , collection_name ):
14
- return self .client [ collection_name ]
11
+ return self .client . get_collection ( collection_name )
15
12
16
13
@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 )
You can’t perform that action at this time.
0 commit comments