<commit_before>"""Module for storing coinmarketcap data in the database."""
import codecs
import coinmarketcap
from datetime import datetime
from decimal import Decimal
import os
import psycopg2 as pg2
import psycopg2.extras as pg2ext
import random
import unittest

# Configuration variables
batchLimit = 1000
tables = {
    "currency": "currency",
    "currency_historical": "currency_historical",
    "market_cap_365": "market_cap_365",
    "market_cap_180": "market_cap_180",
    "market_cap_90": "market_cap_90",
    "market_cap_30": "market_cap_30",
    "market_cap_7": "market_cap_7",
    "trade_volume_usd": "trade_volume_usd"
}

# Pull in postgres configuration information
# Pull in postgres configuration information
dbcFile = open('.pgpass', 'r')
dbcRaw = dbcFile.readline().strip().split(':')
dbcParams = {
    'database': dbcRaw[2],
    'user': dbcRaw[3],
    'password': dbcRaw[4],
    'host': dbcRaw[0],
    'port': dbcRaw[1]
}
dbcFile.close()

# Connection variable
conn = None


def connect():
    """Connect to the database."""
    global conn
    if conn is not None:
        return conn
    else:
        conn = pg2.connect(**dbcParams)
        return conn

<commit_msg>Fixed bug in loading of .pgpass file.<commit_after>"""Module for storing coinmarketcap data in the database."""
import codecs
import coinmarketcap
from datetime import datetime
from decimal import Decimal
import os
import psycopg2 as pg2
import psycopg2.extras as pg2ext
import random
import unittest

# Configuration variables
batchLimit = 1000
tables = {
    "currency": "currency",
    "currency_historical": "currency_historical",
    "market_cap_365": "market_cap_365",
    "market_cap_180": "market_cap_180",
    "market_cap_90": "market_cap_90",
    "market_cap_30": "market_cap_30",
    "market_cap_7": "market_cap_7",
    "trade_volume_usd": "trade_volume_usd"
}

# Pull in postgres configuration information
# Pull in postgres configuration information
dbcFile = open(
    "{0}/.pgpass".format(os.path.dirname(os.path.abspath(__file__))),
    'r')
dbcRaw = dbcFile.readline().strip().split(':')
dbcParams = {
    'database': dbcRaw[2],
    'user': dbcRaw[3],
    'password': dbcRaw[4],
    'host': dbcRaw[0],
    'port': dbcRaw[1]
}
dbcFile.close()

# Connection variable
conn = None


def connect():
    """Connect to the database."""
    global conn
    if conn is not None:
        return conn
    else:
        conn = pg2.connect(**dbcParams)
        return conn


{'fraction_non_alphanumeric': 0.12155591572123177, 'fraction_numerical': 0.02957860615883306, 'mean_word_length': 4.14375, 'pattern_counts': {'":': 16, '<': 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': '24610', 'n_tokens_mistral': 847, 'n_tokens_neox': 802, 'n_words': 219}