python
import MySQLdb
db = MySQLdb.connect(
host='localhost',
user='your_username',
passwd='your_password',
db='your_database'
)
python
import os
backup_path = '/path/to/backup.sql'
os.system(f'mysqldump -u your_username -p your_database > {backup_path}')
python
backup_path = '/path/to/backup.sql'
os.system(f'mysql -u your_username -p your_database < {backup_path}')