<commit_before>import sys

from vfrogr import VfrOgr, Mode
from logger import VfrLogger

class VfrPg(VfrOgr):
    def __init__(self, schema='public', schema_per_file=False, *args):
        VfrOgr.__init__(self, "PostgreSQL", *args)
        self._schema = schema
        self._schema_per_file = schema_per_file
        
        # build dsn string and options
        self._lco_options = []
        if self.odsn:
            # open connection to DB
            self._conn = self._opendb(self.odsn[3:])
        else:
            self._conn = None
        self.schema_list = None
                
    def __del__(self):
        self._conn.close()
        
    def _opendb(self, conn_string):
        try:
            import psycopg2
        except ImportError as e:
            raise VfrError(e)
            
        try:
            conn = psycopg2.connect(conn_string)
        except psycopg2.OperationalError as e:
            raise VfrError("Unable to connect to DB: %s\nTry to define --user and/or --passwd" % e)<commit_msg>Added missing VfrError import fixes #5 (thanks to LukasRychtecky)<commit_after>import sys

from vfrogr import VfrOgr, Mode
from logger import VfrLogger
from exception import VfrError

class VfrPg(VfrOgr):
    def __init__(self, schema='public', schema_per_file=False, *args):
        VfrOgr.__init__(self, "PostgreSQL", *args)
        self._schema = schema
        self._schema_per_file = schema_per_file
        
        # build dsn string and options
        self._lco_options = []
        if self.odsn:
            # open connection to DB
            self._conn = self._opendb(self.odsn[3:])
        else:
            self._conn = None
        self.schema_list = None
                
    def __del__(self):
        self._conn.close()
        
    def _opendb(self, conn_string):
        try:
            import psycopg2
        except ImportError as e:
            raise VfrError(e)
            
        try:
            conn = psycopg2.connect(conn_string)
        except psycopg2.OperationalError as e:
            raise VfrError("Unable to connect to DB: %s\nTry to define --user and/or --passwd" % e)
{'fraction_non_alphanumeric': 0.0829817158931083, 'fraction_numerical': 0.004219409282700422, 'mean_word_length': 1.9192886456908345, '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': '3778900', 'n_tokens_mistral': 656, 'n_tokens_neox': 648, 'n_words': 169}