#!/bin/python3
import ast
import datetime
import sys
import numpy as np
import pandas as pd
from pymongo import MongoClient
import os
import argparse
def get_mongo_client(CONNECT_STR_FILE):
"""读取命令行参数,返回Mongo连接客户端"""
with open(CONNECT_STR_FILE, encoding="utf-8", mode="r") as fr:
connect_shell_str = fr.read().strip()
ip = connect_shell_str.split(':')[0].replace('mongo', '').strip()
port = connect_shell_str.split(':')[1].split('/')[0].strip()
dbname = connect_shell_str.split('/')[1].split('-u')[0].strip()
user = connect_shell_str.split('-u')[1].split('-p')[0].strip()
pwd = connect_shell_str.split('-u')[1].split('-p')[1].strip()
mongo_client = MongoClient(host=ip, port=int(port))
db_client = mongo_client[dbname]
|