mysql-import
Advanced tools
Comparing version 1.0.9 to 1.0.11
/** | ||
* mysql-import - v1.0.9 | ||
* mysql-import - v1.0.11 | ||
* Import .sql into a MySQL database with Node. | ||
@@ -20,21 +20,24 @@ * @author Rob Parham | ||
import(filename){ | ||
var queriesString = fs.readFileSync(filename, 'utf8'); | ||
var queries = parseQueries(queriesString); | ||
return slowLoop(queries, (q,i,d)=>{ | ||
try{ | ||
this.conn.query(q, err=>{ | ||
return new Promise(done=>{ | ||
var queriesString = fs.readFileSync(filename, 'utf8'); | ||
var queries = parseQueries(queriesString); | ||
slowLoop(queries, (q,i,d)=>{ | ||
try{ | ||
this.conn.query(q, err=>{ | ||
/* istanbul ignore next */ | ||
if (err) this.err_handler(err); | ||
else d(); | ||
}); | ||
}catch(e){ | ||
/* istanbul ignore next */ | ||
if (err) this.err_handler(err); | ||
else d(); | ||
}); | ||
}catch(e){ | ||
/* istanbul ignore next */ | ||
this.err_handler(e); | ||
} | ||
this.err_handler(e); | ||
} | ||
}).then(()=>{ | ||
this.conn.end(); | ||
done(); | ||
}); | ||
}); | ||
} | ||
} | ||
importer.version = '1.0.9'; | ||
importer.version = '1.0.11'; | ||
importer.config = function(settings){ | ||
@@ -41,0 +44,0 @@ const valid = settings.hasOwnProperty('host') && typeof settings.host === "string" && |
@@ -45,3 +45,3 @@ { | ||
}, | ||
"version": "1.0.9" | ||
"version": "1.0.11" | ||
} |
@@ -6,3 +6,3 @@ | ||
*Version 1.0.9* | ||
*Version 1.0.11* | ||
@@ -9,0 +9,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) |
@@ -7,17 +7,20 @@ class importer{ | ||
import(filename){ | ||
var queriesString = fs.readFileSync(filename, 'utf8'); | ||
var queries = parseQueries(queriesString); | ||
return slowLoop(queries, (q,i,d)=>{ | ||
try{ | ||
this.conn.query(q, err=>{ | ||
return new Promise(done=>{ | ||
var queriesString = fs.readFileSync(filename, 'utf8'); | ||
var queries = parseQueries(queriesString); | ||
slowLoop(queries, (q,i,d)=>{ | ||
try{ | ||
this.conn.query(q, err=>{ | ||
/* istanbul ignore next */ | ||
if (err) this.err_handler(err); | ||
else d(); | ||
}); | ||
}catch(e){ | ||
/* istanbul ignore next */ | ||
if (err) this.err_handler(err); | ||
else d(); | ||
}); | ||
}catch(e){ | ||
/* istanbul ignore next */ | ||
this.err_handler(e); | ||
} | ||
this.err_handler(e); | ||
} | ||
}).then(()=>{ | ||
this.conn.end(); | ||
done(); | ||
}); | ||
}); | ||
@@ -24,0 +27,0 @@ } |
206368
22
770