Pietrob5 / Password-Manager

A simple password manager that uses encription with python
1 stars 3 forks source link

add: implement the base of database logic and explanations #16

Closed Luquor closed 1 month ago

Luquor commented 1 month ago

Hey @Pietrob5,

I am back from implementing a better way of handling database. There is a package called database with all of my modifications as well as a README file that explains to you some points. I used Docker for a local database, but you can create one online. I did not implement all the logic, juste a few CRUD operations to show you how the package work. You could also create a class to handle the database openning/closing connection, that, I think, might be an even better way of doing things.

I am more a sys admin than a developper, so if you need any help to deploy the database online I can still help you.

Pietrob5 commented 1 month ago

@Luquor Thank you very much, super cool! I'd like to know, if I host the database on Aiven then instead of havinh host="127.0.0.1" Aiven will give me a specific address? Or how does this work? Is it possible to do what you did WITHOUT Docker?

EDIT: If I understand correctly, hosting the database on Aiven is like having it on my local machine (more or less same instructions, query ecc) but I can access it from more devices, right? Or is it more complex than this?

Luquor commented 1 month ago

Aiven will give me a specific address? Or how does this work? Is it possible to do what you did WITHOUT Docker?

That is right, when you create a service in Aiven (only postgresql or mysql are available on that platform), you will get connection information :

Aiven is a online platform that let you create a free database (with some limitations of courses 5Gb of max storage and less compute power). This database will then be accessible online, so even if your personnal computer is shutdown, the database will still be running and accessible by other people because it is running on a server.

That said, you do not want to have the credentials to be visible in your code, simply because you don't want anybody to connect to your database. In that case, you can implement the .env file where you will put the credentials in. That file will never ever be publish on GitHub (use the .gitignore file to exclude it). Then in python, you will is the load_dotenv() functions. Here is a resource that will be helpful for you once you got your database up and running: https://stackoverflow.com/questions/40216311/reading-in-environment-variables-from-an-environment-file

If you want any further help you can add me on discord (same username as this one) if you wish, this will prevent to pollute the project!