Security of encrypted data and decrypting key

I am writing a python program in which I use encryption. The user can set the password and when it will be an input, the database will be decrypted. However, the function needs the decryption key to decrypt. So I thought about hiding that key somewhere(encryption and decryption key will be generated dynamically which means that the user on new device will have another decryption key.). I have no idea where I could hide it, so program could use it, but the user could not crack it.