Hi I´m using python 3.12 and sqlite3 and sqlcipher3 community. My IDE is PyCharm Community 2023.3.5.
When trying to rekey nothing happens an no error is shown! The database is not empty.
As you can see I have tried many different ways. Anyone had the same problem? All suggestions are appreciated.
Here is my code.
def change_key(current_key, new_key):
try:
print(current_key, new_key) # Values are correct
conn = create_connection()
cur = conn.cursor()
# cur.execute("PRAGMA key = '{}'".format(current_key))
# cur.execute("PRAGMA cipher_compatibility = 3")
# cur.execute(f"PRAGMA key = '{current_key}'")
cur.execute("PRAGMA key = '{}'".format(current_key))
# Rekey the database with the new key
# cur.execute(f"PRAGMA rekey = '{new_key}'")
cur.execute("PRAGMA rekey = '{}'".format(new_key))
# Commit changes and close the connection
conn.commit()
conn.close()
except Error as e:
print(e)