<commit_before>/*
 * Copyright (c) 2014, <NAME>, https://bitbucket.org/sgt-kabukiman/
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

var sqlite3 = require('sqlite3');

var Database = function(databaseFile) {
	this.file = databaseFile;
	this.db   = null;
};

Database.prototype = {
	connect: function(callback) {
		var db = new sqlite3.Database('test.sqlite3', sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, function() {
			db.run('CREATE TABLE IF NOT EXISTS channel (name VARCHAR(200))');
			db.run('CREATE TABLE IF NOT EXISTS acl (channel VARCHAR(200), permission VARCHAR(200), user_ident VARCHAR(100))');

			if (typeof callback === 'function') {
				callback(db);
			}
		});

		this.db = db;
	},

	all: function(query, params, callback) {
		return this.db.all(query, params, callback);
	},

	insert: function(table, data, callback) {
		var query, cols, placeholder, placeholders, params, col;

		for (col in data) {
			placeholder = '$' + col;

			cols.push(col);
			placeholders.push(placeholder);
			params[placeholder] = data[col];
		}

		query = 'INSERT INTO ' + table + ' (' + cols.join(',') + ') VALUES (' + placeholders.join(',') + ')';

		this.db.run(query, params, callback);
	},

	del: function(table, where, callback) {
		var query, placeholder, conditions, params, col;

		for (col in where) {
			placeholder = '$' + col;

			conditions.push(col + ' = ' + placeholder);
			params[placeholder] = data[col];
		}

		query = 'DELETE FROM ' + table + ' WHERE ' + conditions.join(' AND ');

		this.db.run(query, params, callback);
	}
};

module.exports = Database;
<commit_msg>fixed static database filename<commit_after>/*
 * Copyright (c) 2014, <NAME>, https://bitbucket.org/sgt-kabukiman/
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

var sqlite3 = require('sqlite3');

var Database = function(databaseFile) {
	this.file = databaseFile;
	this.db   = null;
};

Database.prototype = {
	connect: function(callback) {
		var db = new sqlite3.Database(this.file, sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE, function() {
			db.run('CREATE TABLE IF NOT EXISTS channel (name VARCHAR(200))');
			db.run('CREATE TABLE IF NOT EXISTS acl (channel VARCHAR(200), permission VARCHAR(200), user_ident VARCHAR(100))');

			if (typeof callback === 'function') {
				callback(db);
			}
		});

		this.db = db;
	},

	all: function(query, params, callback) {
		return this.db.all(query, params, callback);
	},

	insert: function(table, data, callback) {
		var query, cols, placeholder, placeholders, params, col;

		for (col in data) {
			placeholder = '$' + col;

			cols.push(col);
			placeholders.push(placeholder);
			params[placeholder] = data[col];
		}

		query = 'INSERT INTO ' + table + ' (' + cols.join(',') + ') VALUES (' + placeholders.join(',') + ')';

		this.db.run(query, params, callback);
	},

	del: function(table, where, callback) {
		var query, placeholder, conditions, params, col;

		for (col in where) {
			placeholder = '$' + col;

			conditions.push(col + ' = ' + placeholder);
			params[placeholder] = data[col];
		}

		query = 'DELETE FROM ' + table + ' WHERE ' + conditions.join(' AND ');

		this.db.run(query, params, callback);
	}
};

module.exports = Database;

{'fraction_non_alphanumeric': 0.15798511734401832, 'fraction_numerical': 0.012306811677160847, 'mean_word_length': 3.8008241758241756, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7270997', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1113, 'n_words': 303}