<commit_before>let log = global.logger.create('MYSQL');
let mysql = require('mysql');
let connectionMethods = require('mysql/lib/Connection')

let DAL = {
	getConnection: cb => cb('NO_CONNECTION')
}
exports.init = (config, dalConfig) => {
	let conf = {
		host: '127.0.0.1',
		user: 'root'
	};
	for(let i in dalConfig){
		conf[i] = dalConfig[i];
	}
	if(!conf.database){
		throw 'wrong mysql config, check database';
	}
	DAL = mysql.createPool(conf);
};

exports.methods = {};
for(let name in connectionMethods.prototype){
	if(name.indexOf('_') == 0){
		continue;
	}

	exports.methods[name] = (...args) => {
		let conn;
		let originalCb = () => {};
		let cb = (...resargs) => {
			if(conn){
				conn.relaese();
			}

			originalCb(...resargs);
			conn = undefined;
		};

		if(typeof args[args.length -1] == 'function' && args[args.length -1] instanceof Function){
			originalCb = args[args.length -1];
			args[args.length -1] = cb;
		}

		DAL.getConnection((err, connection) => {
			if(err){
				return cb(err);
			}

			conn = connection;
			connection[name](...args);
		});
	}
}<commit_msg>bug fix<commit_after>let log = global.logger.create('MYSQL');
let mysql = require('mysql');
let connectionMethods = require('mysql/lib/Connection')

let DAL = {
	getConnection: cb => cb('NO_CONNECTION')
}
exports.init = (config, dalConfig) => {
	let conf = {
		host: '127.0.0.1',
		user: 'root'
	};
	for(let i in dalConfig){
		conf[i] = dalConfig[i];
	}
	if(!conf.database){
		throw 'wrong mysql config, check database';
	}
	DAL = mysql.createPool(conf);
};

exports.methods = {};
for(let name in connectionMethods.prototype){
	if(name.indexOf('_') == 0){
		continue;
	}

	exports.methods[name] = (...args) => {
		let conn;
		let originalCb = () => {};
		let cb = (...resargs) => {
			if(conn){
				conn.release();
			}

			originalCb(...resargs);
			conn = undefined;
		};

		if(typeof args[args.length -1] == 'function' && args[args.length -1] instanceof Function){
			originalCb = args[args.length -1];
			args[args.length -1] = cb;
		}

		DAL.getConnection((err, connection) => {
			if(err){
				return cb(err);
			}

			conn = connection;
			connection[name](...args);
		});
	}
}
{'fraction_non_alphanumeric': 0.19503219871205152, 'fraction_numerical': 0.010119595216191352, 'mean_word_length': 3.3850806451612905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3176123', 'n_tokens_mistral': 886, 'n_tokens_neox': 790, 'n_words': 165}