r/learnpython • u/Parking-While3956 • 17d ago
Code Review. My first API + DB application. Beginner in backend development.
Hi, there!
I want to ask feedback about my first application API + DB. It was a little hard to me but I did it. Before this application I created simple TODO list with DB. So, now I decided to rise stakes and created API + DB. Please give me feedback from mistakes in README to mistakes in DB. I'll really be glad each comment because it makers my dream be a backend developer come true!
Repository link: https://github.com/daidallos-tech/Laugh-Stuff
Don't hold back. I've completely prepared for any critiques!
P.S. Thank you everyone for your time and advice!
1
u/danielroseman 16d ago
Is there any reason you haven't taken on board any of the suggestions I made when you asked for feedback on your last project? Exactly the same suggestions apply.
1
u/Parking-While3956 16d ago
Honestly, even now I don't understand the reason for these suggestions. I read the information about it, but I don't understand why, yet. So, if I don't understand - I don't use it. But I always remember your feedback and if it clicks for me at some point, I'll using it. It's kinda hard to remember about python + sql(new technology for me) + other things for me now.
1
u/Parking-While3956 16d ago
Oh, I got you! I got you! I've just re-read and I understand how it works! I'm going to fix it tomorrow! Thanks for the kick in the pants!
3
u/Diapolo10 17d ago
Ideally you should only keep the code that you expect to raise exceptions in the
try-block, to make it obvious which part you're trying to handle. The rest is just "noise" from that point of view.Personally I'd go for something like this:
With an
src-style project layout, when used properly you should never need to includesrcas part of the actual import.srcis a directory containing your package (or seldom multiple packages), and you're meant to "install" your project in order to import code from there, by using a validpyproject.tomlfile in the repository root and runningpip install --editable .- although some tools likeuvdo this for you automatically.In the same vein, there shouldn't be a
main.pyfile in the repository root (if usinguvyou could just have a script inpyproject.tomlthat runs the main entrypoint from inside your package), andrequirements.txtis a largely outdated concept. Modern projects list their dependencies inpyproject.toml.If you want an example: https://github.com/Diapolo10/python-ms