Estimated reading time: 3 minutes
CRUD ( create, read, update, delete) is a programming language acronym notably for how to manage updates to a database.
It is commonly used when talking about storing data on a database and follows the following rules:
- The ability to create or add new records.
- Be able to read and or retrieve the records.
- If an update is needed, then allow those updates to be posted to the database successfully.
- To ensure records are maintained correctly and deleted where a delete request is requested.
Generally speaking, with crud operations, it is related to persistent storage principles, more information can be found here basic functions of persistent storage (datacadamia.com)
Given these points when using graphical user interfaces, and trying to introduce crud functionality to your database applications, together with the design of the application, should yield:
- Good database design.
- Reducing complexity.
- Eliminate duplication.
- Have consistency.
We have spoken about the use of CRUD, but what are its benefits?
Security roles can be enabled
In addition, CRUD brings they bring structure to what actually can happen on a server, in essence, the ability to apply updates is managed tightly.
Helps put structure around what an application can do
Equally important, in building an application for use by users, knowing what they will do can prompt the designers to ask questions about what the user will actually do.
For example probably when Twitter was been designed, the things that probably where thought of :
Create a tweet – Functionality for the user to create and post a tweet, that gets saved to the database.
Read a tweet – Load all tweets from the database to the users interface.
Update – Allow a user to update their account profile or tweet timeline.
Delete – A user can delete their own tweets, their profile and or account.
Data flows between servers can be managed easier
Similarly, with the modern use of technology and processes moving online, data flows around between lots of people and organizations.
With this in mind, the need to send and receive data has to be managed more efficiently and securely.
As a result, data coming into the server can be controlled as to where it is received, and updated to. This can be accomplished by security roles discussed above.
Using classes with CRUD
The use of Python classes is commonly seen in many applications, for this reason we have used them again below.
Uniquely classes will only help to enhance your computer programme and organization of code, as a result of removing duplication and simplifying the code.
Classes are a very useful way to manage the structure of your code, thus keeping everything centralized.
Sooner or later if this was not implemented the project would become too difficult to manage, and maintenance and updates would become difficult to manage.
In the below video we take you through the steps involved in applying this methodology, using an SQLite database.
We use Python Classes to manage the different requests by the user, the details can be found here
- Main Tkinter window creation
- Exporting data to Excel
- Updating the records
- Filter the records based on user choice
- Deletion of a record.
When applying these updates, we have written the code that will apply the following SQL updates:
As can be seen these four SQL commands are the commonly used across any application to perform these requests in a CRUD application.
It is also important that your data types are synced between your Tkinter application and your SQL logic.
On our YouTube channel you can subscribe to find out more information about SQLite, SQL, Tkinter and many more tips and tricks!