<commit_before>const Driver = require("./Driver.js");
const ConfigHelper = require("./../../helpers/config/config.js");
const mysql = require('mysql');

class MysqlDriver extends Driver {

    constructor() {
        super();

        let configHelper = new ConfigHelper(process.cwd());

        this.settings = configHelper.getSettingsFiles("database");

        this.connection = mysql.createConnection(env("database.mysql"));
    }

    query(queryString, callback) {
        return new Promise((resolve) => {
            this.connection.connect();

            this.connection.query(queryString, (error, results, fields) => {
                if(error) throw error;

                if(callback) {
                    let transformedResults = callback(results);

                    resolve(transformedResults);
                } else {
                    resolve(results);
                }
            });

            this.connection.end();
        });
    }

    find(id, collectionName) {
        const queryString = "SELECT * FROM `" + collectionName + "` WHERE id='" + id + "';";

        return this.query(queryString, (results) => {
            return results ? results[0] : null;
        });
    }

    add(data, collectionName) {
        let queryString = "INSERT INTO `" + collectionName + "` ";
        let columnString = "(";
        let valuesString = "(";

        for (var key in data) {
            if(data.hasOwnProperty(key) && typeof data[key] !== 'function') {
                columnString += key + ",";
                valuesString += "'" + data[key] + "',";
            }
        }

        // remove trailing commas
        columnString = columnString.substring(0, columnString.length - 1);
        valuesString = valuesString.substring(0, valuesString.length - 1);

        columnString += ")";
        valuesString += ")";

        queryString = queryString + columnString + " VALUES " + valuesString + ";";

        console.log(queryString);

        return this.query(queryString, (results) => {
            console.log(results);
        });
    }

}

module.exports = MysqlDriver;<commit_msg>Removed some debugging code<commit_after>const Driver = require("./Driver.js");
const ConfigHelper = require("./../../helpers/config/config.js");
const mysql = require('mysql');

class MysqlDriver extends Driver {

    constructor() {
        super();

        let configHelper = new ConfigHelper(process.cwd());

        this.settings = configHelper.getSettingsFiles("database");

        this.connection = mysql.createConnection(env("database.mysql"));
    }

    query(queryString, callback) {
        return new Promise((resolve) => {
            this.connection.connect();

            this.connection.query(queryString, (error, results, fields) => {
                if(error) throw error;

                if(callback) {
                    let transformedResults = callback(results);

                    resolve(transformedResults);
                } else {
                    resolve(results);
                }
            });

            this.connection.end();
        });
    }

    find(id, collectionName) {
        const queryString = "SELECT * FROM `" + collectionName + "` WHERE id='" + id + "';";

        return this.query(queryString, (results) => {
            return results ? results[0] : null;
        });
    }

    add(data, collectionName) {
        let queryString = "INSERT INTO `" + collectionName + "` ";
        let columnString = "(";
        let valuesString = "(";

        for (var key in data) {
            if(data.hasOwnProperty(key) && typeof data[key] !== 'function') {
                columnString += key + ",";
                valuesString += "'" + data[key] + "',";
            }
        }

        // remove trailing commas
        columnString = columnString.substring(0, columnString.length - 1);
        valuesString = valuesString.substring(0, valuesString.length - 1);

        columnString += ")";
        valuesString += ")";

        queryString = queryString + columnString + " VALUES " + valuesString + ";";

        console.log(queryString);

        return this.query(queryString, (results) => {
            return results.affectedRows == 1 ? true : false;
        });
    }

}

module.exports = MysqlDriver;
{'fraction_non_alphanumeric': 0.13836477987421383, 'fraction_numerical': 0.002562310738411367, 'mean_word_length': 1.9431117203564086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '497648', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1075, 'n_words': 226}