A database-driven desktop software implemented using Python and
tkinter. It executes raw SQL queries against a backend MySQL server via themysql.connectorlibrary to manage and process election data states. The program uses index-based pointers to traverse predefined posts and dynamically generate the GUI.
Caution
This version of my election software is outdated, and may not function as intended.
Check out the latest version at Naresh-x86/Stable-Polling-V2, featuring new, improvised management features and full-fledged interfaces for all aspects of the software!
The state of the application is deeply coupled with the MySQL configuration defined in config.json.
erDiagram
POLLING_DB ||--o{ POST_TABLE : contains
POST_TABLE {
int id PK
varchar name
varchar class
varchar section
varchar image_path
int votes
}
-
Connection Protocol
The script connects via standard TCP socket usinghost,user,password, anddatabasekeys parsed from the JSON configuration payload. -
Relational Mapping
Thepostsarray inconfig.jsondirectly maps to table names in the MySQL database (e.g.,['president', 'vice_president']). -
DML Operations
When a vote is cast via thevote(candidate_id)function, a parameterizedUPDATEquery increments the integer value in thevotescolumn corresponding to the specific primary keyid. A subsequentSELECTquery retrieves the associatednamestring to populate the confirmation modal.
-
Dynamic Generation
The main loop iterates over thepostsarray. For each index, it retrieves the totalnumber_of_candidatesvia afetchall()fetch routine. It then computes coordinate spaces to dynamically place image objects (loaded via PIL) and button widgets horizontally across the screen. -
Modals and Event Loops
The application leveragesToplevelwidgets to spawn borderless notification windows indicating successful transaction commits. It utilizes theroot.after()method to schedule the destruction of the modal and the generation of the subsequent post's candidate list after a specific millisecond delay, bypassing thread-blocking operations. -
Character Replacement Routine
The string manipulation functionreplace_characters()cleans arbitrary underscores and handles formatting before rendering candidate names to thetkinterCanvas elements.
Caution
A running instance of MySQL Server (8.0+) is strictly required before starting the application.
-
Clone & Install Dependencies Initialize your environment and install the required packages:
pip install mysql-connector-python Pillow
-
Database Configuration Import the provided
sample_db.sqlinto your local MySQL server to establish the necessary tables and mock data.mysql -u root -p < sample_db.sqlEnsure your
config.jsonfile is correctly formatted with your local credentials:{ "host": "localhost", "user": "root", "password": "yourpassword", "database": "polling_db", "posts": ["president", "vice_president"] } -
Launch the Application Run the main application script:
python Application.py
| Script Name | Purpose | Operational Scope |
|---|---|---|
Application.py |
Voter Terminal | Primary runtime executable. Handles DML UPDATE statements for incrementing votes. |
DatabaseSelector.py |
Routing | Auxiliary script to change active target databases. |
TableEditor.py |
Administration | Administrative script designed to perform INSERT, UPDATE, and DELETE routines on candidate records. |
Results.py |
Analytics | Issues SELECT queries with ORDER BY votes DESC clauses to render final tallies. |
Tip
The sample_db.sql database dump file is provided and required for structural initialization of the relational tables prior to executing Application.py.
Note
No Artificial Intelligence or automated code generation tools were utilized in the programming of this project. The entire codebase, including logic, UI design, and database structures, was written manually by hand.