将数据从一个数据库复制到另一个数据库并加密数据库数据

时间:2019-05-23 07:00:00

标签: python mysql rsa

我有关于使用python 3.6.4将数据从一个数据库复制到另一个数据库的查询。我已经成功选择并在数据库中插入了数据,我想在将其插入之前使用RSA或任何其他算法对数据进行加密。谢谢

选择数据代码>>

import mysql.connector
from mysql.connector import Error
try:
    mySQLconnection1 = mysql.connector.connect(host='localhost',
                              database='tra',
                              user='tr',
                              password='tr')
    sql_select_Query = "select * from name"
    cursor = mySQLconnection1 .cursor()
    cursor.execute(sql_select_Query)
    records = cursor.fetchall()
    print("Total number of rows in python_developers is - ", cursor.rowcount)
    print ("Printing each row's column values i.e.  developer record")
    for row in records:
        ID= row[0]
        Name= row[1]
        sex= row[2]
        status= row[3]
        mySQLconnection1.commit()
    cursor.close()
except Error as e :
    print ("Error while connecting to MySQL", e)
finally:
    #closing database connection.
    if(mySQLconnection1 .is_connected()):
        mySQLconnection1.close()
        print("MySQL connection is closed")

0 个答案:

没有答案