Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
mysql-import
Advanced tools
Import MySQL files with Node!
via NPM:
$ npm install --save-dev mysql-import
Via Github:
git clone https://github.com/Pamblam/mysql-import.git
const host = 'localhost';
const user = 'root';
const password = 'password';
const database = 'mydb';
const Importer = require('mysql-import');
const importer = new Importer({host, user, password, database});
importer.onProgress(progress=>{
var percent = Math.floor(progress.bytes_processed / progress.total_bytes * 10000) / 100;
console.log(`${percent}% Completed`);
});
importer.import('path/to/dump.sql').then(()=>{
var files_imported = importer.getImported();
console.log(`${files_imported.length} SQL file(s) imported.`);
}).catch(err=>{
console.error(err);
});
new Importer({host, user, password[, database, port, ssl]})
The constructor requires an object with a host
, user
, and password
parameter. Passing in a database parameter is optional. Any of the parameters listed here will work as well.
Importer.prototype.getImported()
Get an array of files imported.
Importer.prototype.setEncoding(encoding)
Set the encoding to use when reading import files. Supported arguments are: utf8
, ucs2
, utf16le
, latin1
, ascii
, base64
, or hex
.
Importer.prototype.use(database)
Set or change the database to import to.
Importer.prototype.onProgress(callback)
Set a callback to be called as the importer processes chunks of the dump file. Callback is provided an object with the following properties:
total_files
: The total files in the queue.file_no
: The number of the current dump file in the queue.bytes_processed
: The number of bytes of the file processed.total_bytes
: The size of the dump file.file_path
: The full path to the dump file.Importer.prototype.onDumpCompleted(callback)
Set a callback to be called after each dump file has completed processing. Callback is provided an object with the following properties:
total_files
: The total files in the queue.file_no
: The number of the current dump file in the queue.file_path
: The full path to the dump file.error
: If there was an error, the error object; if no errors, this will be null
.Importer.prototype.import(...input)
Import an .sql
file or files into the database. This method will take...
.sql
files.
importer.import('path/to/dump1.sql', 'path/to/dum2.sql')
.sql
files.
importer.import('path/to/mysqldumps/')
importer.import(['path/to/dump.sql', 'path/to/dumps/'])
Importer.prototype.disconnect(graceful=true)
Disconnects the connection. If graceful
is switched to false it will force close any connections. This is called automatically after files are imported so typically this method should never be required.
Contributions are more than welcome! Please check out the Contributing Guidelines for this project.
FAQs
Import .sql into a MySQL database with Node.
The npm package mysql-import receives a total of 2,177 weekly downloads. As such, mysql-import popularity was classified as popular.
We found that mysql-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.