A simple Encryption/Decryption script for Databases using PyMySQL and Cryptography library.
The library for dotenv is https://pypi.org/project/python-dotenv/
The main function creates the Backups and Keys Directories if they don't exist.
The encrypt and decrypt function do exactly what they sound like they do.
The library used to make a connection with the database is https://pypi.org/project/PyMySQL/
The scripts collects data from tables in your database.
The data is then saved into .csv files using pandas dataframes.
The .csv files are then encrypted via the the cryptography Fernet library.
To run the script type py Backup.py in the command line obviously.
The file format for the csv files is Tablename-date.csv .
The file format for the key files is Key-date.key .
The main function looks for the first two arguments, the file and the key file.
To run the script type py Encrypt.py "Tablename-date" "Key-date" in the command line.
Note: The script has to be run in the same directory as the Backups and Keys folder access are manually set in the script.
The main function looks for the first two arguments, the encrypted file and the key file.
To run the script type py Decrypt.py "Tablename-date" "Key-date" in the command line.
Note: The script has to be run in the same directory as the Backups and Keys folder access are manually set in the script.