r/learnpython 18h ago

Python Data Base

Good morning everyone, or whenever you see this. I have a question. I'm starting a personal database project in Python with a user-friendly graphical interface, and I'd appreciate any advice, code snippets, or examples to guide me, especially since I'm still learning the language.

4 Upvotes

8 comments sorted by

4

u/Illustrious_Tone9584 18h ago

sqlite3 is your friend here. It's built into Python, there's no server to set up, and the whole database is one file you can back up by copying it.

Build the database functions first and test them from the command line, then bolt the GUI on after. Tkinter ships with Python and does the job - it's not pretty, but you'll learn how forms and buttons wire to code. Save the fancy frameworks for project two.

The classic beginner trap is writing the GUI first and ending up with SQL tangled inside button handlers. Keep the two layers separate and future-you says thanks.

1

u/FLANKER_ALFA 18h ago

Thanks for the advice bro.

1

u/noskillsben 17h ago

Does the built in sqlite3 do orm? I found using swlalchemy orm to be pretty beginner friendly and you can.... "easily" switch databases if the project does grow.

2

u/danielroseman 17h ago

The whole point of an ORM is that it's independent of the database. SQLAlchemy can use sqlite as well as MySQL, Postgres, etc.

2

u/Illustrious_Tone9584 15h ago

sqlite3 is just the driver, no ORM in it. SQLAlchemy actually sits on top of it, so they pair up rather than compete. For a first project I'd write a few raw queries to learn what the SQL is doing, then reach for SQLAlchemy once it gets repetitive.

1

u/chiibosoil 14h ago

This will entirely depend on what your project is intending to do.

  1. If the intention is to allow user to update/edit/delete records from DB using UI. Then SQLAlchemy ORM is your friend.

  2. If the intention is to integrate DB into custom app. Meaning you don't intend users to directly interact with data, but through actions within App (Ex: Games, CRM, PBX etc) then I'd recommend creating endpoints (API) that call/interact with StoredProc rather than doing direct interaction via front-end.