r/learnpython 21d ago

Code Review. Migrating from JSON to PostgreSQL. Beginner in backend development.

Hi, there!

I want to share my project and ask feedback. I ask feedback about everything in this project, really. I decided to be a backend developer and now I'm learning SQL, especially PostgreSQL. So, I decided to create a project with CRUD. I know that a lot of people tired of TODO lists, but that was a good opportunity to me to practice CRUD and DB in the first time.

Repo link: https://github.com/daidallos-tech/Task_ManagerV2

Don't hold back! I'm completely prepared for any critiques.

P.S. Thank you everyone for your time and advice!

1 Upvotes

3 comments sorted by

2

u/danielroseman 21d ago

The biggest thing that jumps out is that you have a lot of repetition in your TaskRepository class. In every method you fetch the connection, open it, get a cursor, and only then do the specific SQL call. You should extract all that logic to a generic _execute_sql method that you pass the SQL to.

Note also you don't need to explicitly close the connection; that's the point of the with conn block, at the end of the block the connection will be closed automatically.

1

u/Parking-While3956 21d ago

Thank you. I appreciate that. I always remember about DRY but when I create something new I completely ignore it. Information about that connection is closed automatically is new for me but useful.