The Rolodex Program is a program written in Python 3 that stores Rolodex information in an SQLite database. The program is run in the console, but is user friendly once downloaded to your computer. A user can add people to the database and the program saves their information for later use.
Reason for Project
The project is based on the original Rolodex, but as a program. The main reason for coding this project was to code a program that used SQLite as its main feature. I was learning SQLite and thought it best to not only follow the examples I was given, but to also work on another, slightly more robust, program. This allowed me to take a pragmatic approach to my learning.
Process
I wrote down the SQL string commands I would need as I knew that they would be the only lines of code that would change every function. The main() function would create the connection and the cursor for the database. In hindsight, I could have created a function to do this; makes code cleaner. Then all I did was create one of the functions I wanted and added that function call to main(). I continued to do this until all the functions I wanted were added.
Code Snippets
The five ‘lookup’ functions (found in db_functions.py; referenced in main.py) all have the ability to search parts of each column. For example, in the code below, the function will search the ’email’ column in the database and will print all the entries that have the user specified input in their ’email.’
def email_lookup(cursor): """Searches the database for user's input; characters of email(s) to lookup. Note: The function will also work with a completed email. Args: cursor (sqlite3.Cursor): Cursor in database file. """ email = input("Email to lookup: ") sql = 'select * from people where email like "%{}%"' results = cursor.execute(sql.format(email)) people = results.fetchall() for person in people: print(person)
The same goes for all functions with ‘lookup’ in their name. At first this was not what I wanted. But, the function seemed more useful this way and so I kept it like that.
Overall
The program did not take too long to code and it got me using SQLite commands. As improvements, I could see the program implementing another table for businesses in the database. If you want a program that stores contact information, this program does it.
If you have any comments or suggestions for the program, leave a comment below or fork, improve, and submit a pull request for the project. I am always looking for ways to improve my craft!