jmrashed-sql-import-export
v1.0.0
Published
A command-line tool for importing large SQL files into a MySQL database and exporting the database daily. This package provides an easy way to manage your SQL operations directly from the command line.
Downloads
74
Readme
jmrashed-sql-import-export
A command-line tool for importing large SQL files into a MySQL database and exporting the database daily. This package provides an easy way to manage your SQL operations directly from the command line.
Features
- Import SQL files into your MySQL database.
- Schedule daily exports of the database.
- Simple command-line interface for ease of use.
Installation
To install the package, run the following command:
npm install jmrashed-sql-import-export
Usage
After installation, you can use the sql-manager
command in your terminal.
Importing SQL Files
To import an SQL file into your database, use the following command:
sql-manager import <path/to/your/file.sql>
Example:
sql-manager import path/to/your/file.sql
Scheduling Daily Export
To schedule a daily export of your database, use the following command:
sql-manager export <path/to/backup/directory>
Example:
sql-manager export /path/to/backup/directory
This will schedule a daily export at midnight to the specified directory.
Configuration
You need to configure your database connection settings in the cli.js
file. Update the following section with your MySQL database credentials:
// Database configuration
const config = {
host: 'localhost', // Your database host
user: 'your_username', // Your database username
password: 'your_password', // Your database password
database: 'your_database' // Your database name
};
Requirements
- Node.js (v12 or later)
- MySQL database
Dependencies
- mysql2 - For connecting to the MySQL database.
- commander - For building the CLI.
- node-cron - For scheduling daily exports.
- fs - For file system operations.
- path - For handling file paths.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please submit a pull request or open an issue for any improvements or bug fixes.
Contact
For any inquiries, please contact me at [[email protected]].