<commit_before><?php
	
	function sql_open() {
		global $pdo;
		if($pdo) return true;
		
		try {
			return $pdo = new PDO(DB_TYPE . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_USER, DB_PASSWORD);
		} catch(PDOException $e) {
			error('Database error.');
		}
	}
	
	function sql_close() {
		global $pdo;
		$pdo = NULL;
	}
	
	function prepare($query) {
		global $pdo;
		return $pdo->prepare($query);
	}
	
	function query($query) {
		global $pdo;
		return $pdo->query($query);
	}
	
	function db_error($PDOStatement=null) {
		global $pdo;
		if(isset($PDOStatement)) {
			$err = $PDOStatement->errorInfo();
			return $err[2];
		} else {
			$err = $pdo->errorInfo();
			return $err[2];
		}
	}
?><commit_msg>Extened error message on database failure<commit_after><?php
	
	function sql_open() {
		global $pdo;
		if($pdo) return true;
		
		try {
			return $pdo = new PDO(DB_TYPE . ':host=' . DB_SERVER . ';dbname=' . DB_DATABASE, DB_USER, DB_PASSWORD);
		} catch(PDOException $e) {
			$message = $e->getMessage();
			
			// Remove any sensitive information
			$message = str_replace(DB_USER, '<em>hidden</em>', $message);
			$message = str_replace(DB_PASSWORD, '<em>hidden</em>', $message);
			
			// Print error
			error('Database error: ' . $message);
		}
	}
	
	function sql_close() {
		global $pdo;
		$pdo = NULL;
	}
	
	function prepare($query) {
		global $pdo;
		return $pdo->prepare($query);
	}
	
	function query($query) {
		global $pdo;
		return $pdo->query($query);
	}
	
	function db_error($PDOStatement=null) {
		global $pdo;
		if(isset($PDOStatement)) {
			$err = $PDOStatement->errorInfo();
			return $err[2];
		} else {
			$err = $pdo->errorInfo();
			return $err[2];
		}
	}
?>
{'fraction_non_alphanumeric': 0.1768545994065282, 'fraction_numerical': 0.002373887240356083, 'mean_word_length': 3.413612565445026, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 18, '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': '1151507', 'n_tokens_mistral': 735, 'n_tokens_neox': 642, 'n_words': 132}