<commit_before>package EnsEMBL::Web::Data::Genomic;

use strict;
use warnings;

use base qw/EnsEMBL::Web::Data/;
use DBI;

my %dbh;

##
## EnsEMBL::Web::Data::Analysis::connect($db_info) - dynamic db connection
##
sub connect {
    my $self    = shift;
    my $species = shift || __PACKAGE__->species_defs->ENSEMBL_PRIMARY_SPECIES;
    my $db      = shift || 'DATABASE_CORE';
    my $db_info =  __PACKAGE__->species_defs->get_config($species, 'databases');

    my $dsn = join(':',
      'dbi',
      'mysql',
      $db_info->{$db}{'NAME'},
      $db_info->{$db}{'HOST'},
      $db_info->{$db}{'PORT'},
    );

    if ($dbh{$dsn}) {
        $self->{__current_dbh} = $dbh{$dsn};
    } else {
        $self->{__current_dbh} = $dbh{$dsn} = DBI->connect_cached(
            $dsn,
            __PACKAGE__->species_defs->DATABASE_WRITE_USER,
            __PACKAGE__->species_defs->DATABASE_WRITE_PASS,
            {
              RaiseError => 1,
              PrintError => 1,
              AutoCommit => 1,
            }
        );
        if (not $self->{__current_dbh}) {
            warn "Could not connect to '$dsn' $DBI::errstr";
            return 0;
        }
    }
    return 1;
}
 
sub db_Main {
    my $self = shift;

    return $self->SUPER::db_Main
      unless ref $self;
      
    return $self->{__current_dbh};
}

1;<commit_msg>*** empty log message ***<commit_after>package EnsEMBL::Web::Data::Genomic;

use strict;
use warnings;

use base qw/EnsEMBL::Web::Data/;
use DBI;

my %dbh;

##
## EnsEMBL::Web::Data::Analysis::connect($db_info) - dynamic db connection
##
sub connect {
    my $self    = shift;
    my $species = shift || __PACKAGE__->species_defs->ENSEMBL_PRIMARY_SPECIES;
    my $db      = shift || 'DATABASE_CORE';
    my $db_info =  __PACKAGE__->species_defs->get_config($species, 'databases');

    my $dsn = join(':',
      'dbi',
      'mysql',
      $db_info->{$db}{'NAME'},
      $db_info->{$db}{'HOST'},
      $db_info->{$db}{'PORT'},
    );

    if ($dbh{$dsn}) {
        $self->{__current_dbh} = $dbh{$dsn};
    } else {
        $self->{__current_dbh} = $dbh{$dsn} = DBI->connect_cached(
            $dsn,
            __PACKAGE__->species_defs->DATABASE_WRITE_USER,
            __PACKAGE__->species_defs->DATABASE_WRITE_PASS,
            {
              RaiseError => 1,
              PrintError => 1,
              AutoCommit => 1,
            }
        );
        if (not $self->{__current_dbh}) {
            warn "Could not connect to '$dsn' $DBI::errstr";
            return 0;
        }
    }
    return 1;
}
 
sub db_Main {
    my $self = shift;

    return undef
      unless ref $self;
      
    return $self->{__current_dbh};
}

1;
{'fraction_non_alphanumeric': 0.1655455904334828, 'fraction_numerical': 0.004484304932735426, 'mean_word_length': 2.194510739856802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, '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': '5616455', 'n_tokens_mistral': 1010, 'n_tokens_neox': 967, 'n_words': 175}