<commit_before>const config = require("./config").root();

let pg = require("pg");
let credentials = config.db.password ? `${config.db.user}:${config.db.password}` : config.db.user;
let constr = `postgres://${credentials}@${config.db.host}/${config.db.user}`;

function getConnection() {
  return new Promise(function (resolve, reject) {
    pg.connect(constr, function (err, client, done) {
      if (err) {
        reject(err);
      } else {
        resolve([client, done]);
      }
    });
  });
}

// FIXME: make these so they don't need to be exported<commit_msg>URL-encode the Postgres user and password.<commit_after>const config = require("./config").root();

let pg = require("pg");

let user = encodeURIComponent(config.db.user);
let credentials = config.db.password ? `${user}:${encodeURIComponent(config.db.password)}` : user;
let constr = `postgres://${credentials}@${config.db.host}/${user}`;

function getConnection() {
  return new Promise(function (resolve, reject) {
    pg.connect(constr, function (err, client, done) {
      if (err) {
        reject(err);
      } else {
        resolve([client, done]);
      }
    });
  });
}

// FIXME: make these so they don't need to be exported
{'fraction_non_alphanumeric': 0.17759336099585063, 'fraction_numerical': 0.0, 'mean_word_length': 3.550943396226415, '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': '2592280', 'n_tokens_mistral': 373, 'n_tokens_neox': 381, 'n_words': 91}