mirror of
https://github.com/autistic-symposium/blockchain-data-engineering-toolkit.git
synced 2025-04-26 02:39:15 -04:00
add db async methods
This commit is contained in:
parent
2d346fec48
commit
8b46c0c6b2
@ -4,12 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import pymongo
|
import pymongo
|
||||||
|
from src.utils import os_utils
|
||||||
|
|
||||||
env_vars = os_utils.load_config()
|
|
||||||
url = env_vars['MONGODB_URL']
|
|
||||||
db_name = env_vars['MONGODB_DB_NAME']
|
|
||||||
collection = env_vars['MONGODB_COLLECTION_NAME']
|
|
||||||
|
|
||||||
|
|
||||||
############################################
|
############################################
|
||||||
@ -19,8 +14,13 @@ collection = env_vars['MONGODB_COLLECTION_NAME']
|
|||||||
def _get_db_collection():
|
def _get_db_collection():
|
||||||
"""Connect to the database."""
|
"""Connect to the database."""
|
||||||
|
|
||||||
|
env_vars = os_utils.load_config()
|
||||||
|
url = env_vars['MONGODB_URL']
|
||||||
|
db_name = env_vars['MONGODB_DB_NAME']
|
||||||
|
collection = env_vars['MONGODB_COLLECTION_NAME']
|
||||||
|
|
||||||
client = pymongo.MongoClient(url)
|
client = pymongo.MongoClient(url)
|
||||||
database = client.balances
|
database = client[db_name]
|
||||||
return database[collection]
|
return database[collection]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user