Installations
npm install mysql2-import
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>5.0.0
Node Version
14.16.1
NPM Version
6.14.12
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
mar0xy
Download Statistics
Total Downloads
100,546
Last Day
14
Last Week
257
Last Month
1,518
Last Year
44,325
GitHub Statistics
110 Commits
1 Forks
4 Branches
1 Contributors
Bundle Size
571.37 kB
Minified
253.29 kB
Minified + Gzipped
Package Meta Information
Latest Version
5.0.22
Package Id
mysql2-import@5.0.22
Size
39.53 kB
NPM Version
6.14.12
Node Version
14.16.1
Publised On
03 May 2021
Total Downloads
Cumulative downloads
Total Downloads
100,546
Last day
-87.8%
14
Compared to previous day
Last week
-47%
257
Compared to previous week
Last month
-41.4%
1,518
Compared to previous month
Last year
24.1%
44,325
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
7
Based on Pamblam's mysql-import just edited to work for mysql2
Import MySQL files with Node!
Table of Contents
Install
via NPM:
$ npm install --save-dev mysql-import
Via Github:
git clone https://github.com/Pamblam/mysql-import.git
TLDR:
1const host = 'localhost'; 2const user = 'root'; 3const password = 'password'; 4const database = 'mydb'; 5 6const Importer = require('mysql-import'); 7const importer = new Importer({host, user, password, database}); 8 9// New onProgress method, added in version 5.0! 10importer.onProgress(progress=>{ 11 var percent = Math.floor(progress.bytes_processed / progress.total_bytes * 10000) / 100; 12 console.log(`${percent}% Completed`); 13}); 14 15importer.import('path/to/dump.sql').then(()=>{ 16 var files_imported = importer.getImported(); 17 console.log(`${files_imported.length} SQL file(s) imported.`); 18}).catch(err=>{ 19 console.error(err); 20});
Methods
new Importer({host, user, password[, database]})
The constructor requires an object with a host
, user
, and password
parameter. Passing in a database parameter is optional.
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)
(New in v. 5.0!) - 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)
(New in v. 5.0!) - 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 benull
.
Importer.prototype.import(...input)
Import an .sql
file or files into the database. This method will take...
- Any number of paths to individual
.sql
files.importer.import('path/to/dump1.sql', 'path/to/dum2.sql')
- Any number of paths that contain any number of
.sql
files.importer.import('path/to/mysqldumps/')
- Any number of arrays containing either of the above.
importer.import(['path/to/dump.sql', 'path/to/dumps/'])
- Any combination of any of the above.
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.
Contributing
Contributions are more than welcome! Please check out the Contributing Guidelines for this project.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
35 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-957j-59c2-j692
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-m5pj-vjjf-4m3h
- Warn: Project is vulnerable to: GHSA-j383-35pm-c5h4
- Warn: Project is vulnerable to: GHSA-rm36-94g8-835r
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
1.7
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More