Socket
Socket
Sign inDemoInstall

mysql-import

Package Overview
Dependencies
11
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.20 to 5.0.21

test/sample_dump_files/test4.sql

10

mysql-import.js
/**
* mysql-import - v5.0.20
* mysql-import - v5.0.21
* Import .sql into a MySQL database with Node.

@@ -19,3 +19,3 @@ * @author Rob Parham

* mysql-import - Importer class
* @version 5.0.20
* @version 5.0.21
* https://github.com/Pamblam/mysql-import

@@ -373,3 +373,3 @@ */

*/
Importer.version = '5.0.20';
Importer.version = '5.0.21';

@@ -529,2 +529,6 @@ module.exports = Importer;

checkEndOfQuery(){
if(this.seekingDelimiter){
return false;
}
var query = false;

@@ -531,0 +535,0 @@ var demiliterFound = false;

@@ -45,3 +45,3 @@ {

},
"version": "5.0.20"
}
"version": "5.0.21"
}

@@ -7,3 +7,3 @@

*Version 5.0.20* ([NPM](https://www.npmjs.com/package/mysql-import)) ([Github](https://github.com/Pamblam/mysql-import/))
*Version 5.0.21* ([NPM](https://www.npmjs.com/package/mysql-import)) ([Github](https://github.com/Pamblam/mysql-import/))

@@ -10,0 +10,0 @@ [![Build Status](https://api.travis-ci.org/Pamblam/mysql-import.svg?branch=master)](https://travis-ci.org/Pamblam/mysql-import/) [![Coverage Status](https://coveralls.io/repos/github/Pamblam/mysql-import/badge.svg?branch=master)](https://coveralls.io/github/Pamblam/mysql-import?branch=master)

@@ -128,2 +128,6 @@

checkEndOfQuery(){
if(this.seekingDelimiter){
return false;
}
var query = false;

@@ -130,0 +134,0 @@ var demiliterFound = false;

@@ -1,5 +0,5 @@

const mysql = require('mysql');
var con;
var log_bin_trust_function_creators;

@@ -36,3 +36,3 @@ /**

*/
function mysqlConnect(config){
async function mysqlConnect(config){
con = mysql.createConnection({

@@ -43,2 +43,5 @@ host: config.host,

});
var res = await query("SHOW GLOBAL VARIABLES LIKE 'log_bin_trust_function_creators';");
log_bin_trust_function_creators = res[0].Value
await query("SET GLOBAL log_bin_trust_function_creators = 1;");
}

@@ -63,3 +66,4 @@

function closeConnection(){
async function closeConnection(){
await query("SET GLOBAL log_bin_trust_function_creators = '"+log_bin_trust_function_creators+"';");
con.end();

@@ -66,0 +70,0 @@ }

@@ -1,2 +0,1 @@

// SET THESE FOR LOCAL TESTING ONLY!

@@ -18,53 +17,56 @@ // RESET THEM TO '' BEFORE COMMITING CHANGES!

mysqlConnect(config);
var fs, MySQLImport, importer, start_time;
const fs = require('fs');
const MySQLImport = require('../mysql-import.js');
const importer = new MySQLImport(config);
describe('Running All Tests', ()=>{
// For coverage
importer.onProgress('Not a function');
importer.onDumpCompleted('Not a function');
before(async function(){
start_time = new Date();
await mysqlConnect(config);
importer.onProgress(progress=>{
var percent = Math.floor(progress.bytes_processed / progress.total_bytes * 10000) / 100;
var filename = progress.file_path.split("/").pop();
var message = `\tFile ${progress.file_no} of ${progress.total_files}: `+
`processing ${filename} - ${percent}% Complete`;
if(process.stdout.isTTY){
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(message);
}else{
console.log(message);
}
});
fs = require('fs');
MySQLImport = require('../mysql-import.js');
importer = new MySQLImport(config);
importer.onDumpCompleted(status=>{
var filename = status.file_path.split("/").pop();
var message;
if(status.error){
message = `\tFile ${status.file_no} of ${status.total_files}: `+
`Was not processed.\n`;
}else{
message = `\tFile ${status.file_no} of ${status.total_files}: `+
`Completed processing ${filename}\n`;
}
if(process.stdout.isTTY){
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(message);
}else{
console.log(message);
}
});
// For coverage
importer.onProgress('Not a function');
importer.onDumpCompleted('Not a function');
importer.setEncoding('utf8');
importer.onProgress(progress=>{
var percent = Math.floor(progress.bytes_processed / progress.total_bytes * 10000) / 100;
var filename = progress.file_path.split("/").pop();
var message = `\tFile ${progress.file_no} of ${progress.total_files}: `+
`processing ${filename} - ${percent}% Complete`;
if(process.stdout.isTTY){
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(message);
}else{
console.log(message);
}
const start_time = new Date();
});
describe('Running All Tests', ()=>{
before(async function(){
importer.onDumpCompleted(status=>{
var filename = status.file_path.split("/").pop();
var message;
if(status.error){
message = `\tFile ${status.file_no} of ${status.total_files}: `+
`Was not processed.\n`;
}else{
message = `\tFile ${status.file_no} of ${status.total_files}: `+
`Completed processing ${filename}\n`;
}
if(process.stdout.isTTY){
process.stdout.clearLine();
process.stdout.cursorTo(0);
process.stdout.write(message);
}else{
console.log(message);
}
});
importer.setEncoding('utf8');
await createTestDB('mysql-import-test-db-1');

@@ -75,10 +77,10 @@ await createTestDB('mysql-import-test-db-2');

});
after(async ()=>{
await destroyTestDB('mysql-import-test-db-1');
await destroyTestDB('mysql-import-test-db-2');
closeConnection();
await closeConnection();
console.log(`All tests completed in ${(new Date() - start_time)/1000} seconds.`);
});
it('Import two tables', async ()=>{

@@ -93,3 +95,3 @@ var tables = await query("SHOW TABLES;");

});
it('5 Rows With Semicolons Imported Into Test DB', async ()=>{

@@ -99,3 +101,3 @@ var rows = await query('SELECT * FROM `importtest` WHERE `doc` LIKE "%;%";');

});
it('Reuse Importer', async ()=>{

@@ -106,3 +108,3 @@ await importer.import(__dirname+'/sample_dump_files/test2.sql');

});
it('5 Rows Inserted in 2nd Table', async ()=>{

@@ -112,3 +114,3 @@ var rows = await query("SELECT * FROM `test_table_2`;");

});
it('Import Array, Directory', async ()=>{

@@ -122,3 +124,3 @@ await importer.import(

});
it('Change database', async ()=>{

@@ -131,8 +133,13 @@ query("USE `mysql-import-test-db-2`;");

});
it('Test imported', async ()=>{
var files = importer.getImported();
expect(files.length).to.equal(10);
expect(files.length).to.equal(11);
});
it('Test imported function', async ()=>{
var funcs = await query("SHOW FUNCTION STATUS LIKE 'testfunc';");
expect(funcs.length).to.equal(1);
});
it('Test unsupported encoding', ()=>{

@@ -147,3 +154,3 @@ var error;

});
it('Test manually connecting', async ()=>{

@@ -161,3 +168,3 @@ var host = config.host;

});
it('Test live DB change', async ()=>{

@@ -176,3 +183,3 @@ await importer._connect();

});
it('Single file error handling', async ()=>{

@@ -187,3 +194,3 @@ var error;

});
it('Test fake sql file.', async ()=>{

@@ -199,3 +206,3 @@ var fake_sql_file = __dirname+"/sample_dump_files/more_sample_files/not_sql.txt";

});
it('Test importing broken file.', async ()=>{

@@ -212,3 +219,3 @@ var fake_sql_file = __dirname+"/broken_dump_files/dump.sql";

});
it('Test diconnect function.', async ()=>{

@@ -222,3 +229,3 @@ try{

});
it('Test fileExist method.', async ()=>{

@@ -233,3 +240,3 @@ var error;

});
it('Test statFile method.', async ()=>{

@@ -244,3 +251,3 @@ var error;

});
it('Test readDir method.', async ()=>{

@@ -255,3 +262,3 @@ var error;

});
it('Testing path parser.', async ()=>{

@@ -266,3 +273,4 @@ var error;

});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc