!function(){
    const config = require("fs").readFileSync('./db_config.json', 'utf8');
    exports.doMysqlWork = function(f = function(conn=connection, close=function(){}){}){
        const mysql = require("mysql");
        const connection = mysql.createConnection(JSON.parse(config));

        connection.connect(); // prisijungimas
        function close(){
            connection.end();
        }
        if (typeof f === "function")
            f(connection, close);
    }
}();