<commit_before>from datetime import datetime
from random import shuffle

import gridfs
import pymongo
import pytz
from bson.codec_options import CodecOptions
from bson.objectid import ObjectId
from langdetect import detect
from upol_search_engine import settings
from upol_search_engine.utils import urls


def create_client():
    client = pymongo.MongoClient(
        settings.CONFIG.get('Settings', 'mongo_db_server'),
        settings.CONFIG.getint('Settings', 'mongo_db_port'),
        user=settings.CONFIG.get('Settings', 'mongo_db_user'),
        password=settings.CONFIG.get('Settings', 'mongo_db_password'),
        authSource='admin',
        authMechanism='SCRAM-SHA-1',
        maxPoolSize=None)

    return client


def get_database(limit_domain, client):
    database_name = urls.domain_replace_dots(limit_domain)
    database = client[database_name]

    return database


def get_stats_database(client):
    return client["stats"]


def drop_database(db_name):
    client = create_client()
    client.drop_database(db_name)

<commit_msg>Fix mongo auth<commit_after>from datetime import datetime
from random import shuffle

import gridfs
import pymongo
import pytz
from bson.codec_options import CodecOptions
from bson.objectid import ObjectId
from langdetect import detect
from upol_search_engine import settings
from upol_search_engine.utils import urls


def create_client():
    client = pymongo.MongoClient(
        settings.CONFIG.get('Settings', 'mongo_db_server'),
        settings.CONFIG.getint('Settings', 'mongo_db_port'),
        username=settings.CONFIG.get('Settings', 'mongo_db_user'),
        password=settings.CONFIG.get('Settings', 'mongo_db_password'),
        authSource='admin',
        authMechanism='SCRAM-SHA-1',
        maxPoolSize=None)

    return client


def get_database(limit_domain, client):
    database_name = urls.domain_replace_dots(limit_domain)
    database = client[database_name]

    return database


def get_stats_database(client):
    return client["stats"]


def drop_database(db_name):
    client = create_client()
    client.drop_database(db_name)


{'fraction_non_alphanumeric': 0.08810990052108006, 'fraction_numerical': 0.0009474182851729038, 'mean_word_length': 4.543307086614173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6180035', 'n_tokens_mistral': 638, 'n_tokens_neox': 622, 'n_words': 140}