Modern applications rely heavily on structured data. As a Software Engineering student at Ensign College, I explored how to bridge the gap between Python logic and relational databases. This project is a custom-built Database Management Wrapper using SQLite3. Instead of writing raw SQL for every task, I developed a modular system that automates data creation, retrieval, and modification, ensuring consistency and reducing repetitive code.
The core philosophy of this project is Dynamic Query Generation. By passing dictionaries and lists as arguments, the program "writes" the SQL commands on the fly. This abstraction allows developers to focus on data structures rather than syntax errors in long SQL strings.
The create_table function takes a list of dictionaries to define a schema. It handles data types and modifiers (like primary key) automatically.
Python
# Iterating over field definitions to build the table structure
for f in fields:
sql += f['name'] + " " + f['dtype'] + " " + f['modify'] + ","
To prevent SQL Injection—a major security vulnerability—I used parameterized queries. By using ? placeholders, the program ensures that user input is treated as data rather than executable code.
Python
# Using placeholders for secure data handling
sql += " VALUES(" + ",".join(["?" for _ in _fieldata]) + ")"
cursor.execute(sql, _fieldata)
This project showcases a complete lifecycle of data management:
WHERE clauses.