Move "connect to database" into db/util.py
This commit is contained in:
11
mediagoblin/db/util.py
Normal file
11
mediagoblin/db/util.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import mongokit
|
||||
|
||||
|
||||
def connect_database(app_config):
|
||||
"""Connect to the main database, take config from app_config"""
|
||||
port = app_config.get('db_port')
|
||||
if port:
|
||||
port = asint(port)
|
||||
connection = mongokit.Connection(
|
||||
app_config.get('db_host'), port)
|
||||
return connection
|
||||
Reference in New Issue
Block a user