|
|
|
|
@ -1,26 +1,31 @@
|
|
|
|
|
import logging
|
|
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
from typing import Dict
|
|
|
|
|
|
|
|
|
|
from kedro.framework.session import KedroSession
|
|
|
|
|
|
|
|
|
|
from actesdataset import JSONDataSetCollection
|
|
|
|
|
|
|
|
|
|
import pymongo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def populate_mongo(jsondoc: JSONDataSetCollection, storage_ip: str, db_name: str, db_collection_name: str) -> None:
|
|
|
|
|
def populate_mongo(jsondoc: JSONDataSetCollection, storage_ip: str, db_name: str, db_collection_name: str, mongodb_admin: str, mongodb_password: str) -> None:
|
|
|
|
|
|
|
|
|
|
#logger.info(storage_ip)
|
|
|
|
|
#logger.info(db_name)
|
|
|
|
|
#logger.info(db_collection_name)
|
|
|
|
|
jsondatasets = jsondoc.datasets
|
|
|
|
|
housename = jsondoc._housename
|
|
|
|
|
mongodb_url = "mongodb://{}:27017/".format(storage_ip)
|
|
|
|
|
#mongodb://%s:%s@149.202.41.75:27017' % (username, password)
|
|
|
|
|
# FIXME passer en parametres
|
|
|
|
|
username = urllib.parse.quote_plus(mongodb_admin)
|
|
|
|
|
password = urllib.parse.quote_plus(mongodb_password)
|
|
|
|
|
mongodb_url = f"mongodb://{username}:{password}@{storage_ip}:27017/"
|
|
|
|
|
#mongodb_url = "mongodb://{}:27017/".format(storage_ip)
|
|
|
|
|
logger.info("connection to the mongodb server: " + mongodb_url)
|
|
|
|
|
|
|
|
|
|
# pymongo settings
|
|
|
|
|
|