<commit_before>import os
import psycopg2
from urlparse import urlparse


def database_connection():
    docker_db_host = os.getenv('DB_PORT_5432_TCP_ADDR', None)
    if docker_db_host:
        database_url = 'postgres://postgres@{0}:5432/postgres'.format(docker_db_host)
    else:
        database_url = os.getenv('DATABASE_URL', None)

    assert database_url

    parsed = urlparse(database_url)
    user = parsed.username
    password = <PASSWORD>
    host = parsed.hostname
    port = parsed.port<commit_msg>Refactor<commit_after>import os
import psycopg2
from urlparse import urlparse


def database_url():
    docker_db_host = os.getenv('DB_PORT_5432_TCP_ADDR', None)
    if docker_db_host:
        database_url = 'postgres://postgres@{0}:5432/postgres'.format(docker_db_host)
    else:
        database_url = os.getenv('DATABASE_URL', None)
    assert database_url
    return database_url


def database_connection():
    parsed = urlparse(database_url())
    user = parsed.username
    password = parsed.password
    host = parsed.hostname
    port = parsed.port
{'fraction_non_alphanumeric': 0.09345794392523364, 'fraction_numerical': 0.018691588785046728, 'mean_word_length': 3.868181818181818, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2602448', 'n_tokens_mistral': 359, 'n_tokens_neox': 343, 'n_words': 69}