<commit_before>import sqlite3
import psycopg2
import psycopg2.extras

def connect(*args, **kwargs):
    return connect_psycopg2(*args, **kwargs)

def connect_sqlite3(*args, **kwargs):
    db = sqlite3.connect(*args, **kwargs)

    db.row_factory = sqlite3.Row

    return db

def connect_psycopg2(*args, **kwargs):
    db = psycopg2.connect(*args, **kwargs)

    db.cursor_factory = psycopg2.extras.DictCursor

    return db
<commit_msg>Changes database connection string to a connection uri<commit_after>import sqlite3
import psycopg2
import psycopg2.extras
import urlparse

def connect(uri):
    result = urlparse.urlparse(uri)
    username = result.username
    password = <PASSWORD>
    database = result.path[1:]
    hostname = result.hostname

    if result.scheme == 'postgres' or result.scheme == 'postgresql':
        return connect_psycopg2(
                database=database,
                user=username,
                password=password,
                host=hostname)

    return None

def connect_sqlite3(*args, **kwargs):
    db = sqlite3.connect(*args, **kwargs)

    db.row_factory = sqlite3.Row

    return db

def connect_psycopg2(*args, **kwargs):
    db = psycopg2.connect(*args, **kwargs)

    db.cursor_factory = psycopg2.extras.DictCursor

    return db

{'fraction_non_alphanumeric': 0.10460577673692428, 'fraction_numerical': 0.01639344262295082, 'mean_word_length': 3.2876254180602005, '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': '7186532', 'n_tokens_mistral': 417, 'n_tokens_neox': 397, 'n_words': 93}