This project provides a Python script to export the contents of a MySQL database to a YAML file. The script allows you to specify tables to be excluded from the export and stores the resulting YAML files in an exports
directory with a timestamp in the filename to prevent accidental overwrites.
- Python 3
- PyMySQL
- PyYAML
-
Clone the repository:
git clone https://github.com/JurajCekan/mysql_export_to_yaml.git
-
Change to the project directory:
cd mysql_export_to_yaml
-
Install the required packages:
pip install -r requirements.txt
-
Copy the
config-template.yaml
file and rename it toconfig.yaml
:cp config-template.yaml config.yaml
-
Edit
config.yaml
to set your MySQL connection credentials and specify any tables you want to exclude from the export:mysql: host: localhost user: your_username password: your_password database: your_database exclude_tables: - table_to_exclude1 - table_to_exclude2
Run the script to export your MySQL database contents to a YAML file:
python mysql_export_to_yaml.py
The exported YAML files will be saved in the exports
directory with a timestamp in the filename, e.g. export_YYYYMMDD-HHMM.yaml
.
If you would like to contribute to this project, please feel free to submit a pull request or open an issue on the repository.