Python functionality to copy database using transportable tablespaces. Includes export.py
to
export tables of an existing database and import.py
to import that data into a new database.
With anaconda:
conda create -n sql mysql-connector-python mysqlclient ipython python=3
conda activate sql
With pip:
pip install mysqlclient
pip install mysql-connector-python
- Rename
configTemplate.py
toconfig.py
- Update arguments in
config.py
to correspond to correct MySQL database
python export.py
python import.py
Or via commandline arguments:
./export.py -v false -db test -u root -p pwd -c localhost -dp /usr/local/var/mysql/ -e export/
./import.py -v false
Note: command line arguments will override config.py settings.
- Not sure if I need to do something with .cfg files
- This setup was replicated from a blog about transportable table space
- Ideally export would be run nightly on production to produce export files and there would be an intermediate (yet to be written) script to rsync the remote export to the local import directory