
Posted on by Jim Skon
Goal
To examine and set up an SQL based C++ or Python Web phone directory using MySQL
You will use from the following project: https://github.com/jimskon/PhoneBookComplete or https://github.com/jimskon/PhoneBookPython
The project can be tried here: http://jimskon.com/class/softdev/skon/PhoneAppComplete/phoneApp.html or http://jimskon.com/class/softdev/skon/PhoneAppPython/phoneApp.html
Method
Step 1 – Get the demo software running from your account and with your Database:
Download either the C++ or Python code from the github project (links above)
Get the PhoneBookComplete or PhoneBookPython project with the following command (only works if you have a github account, and have accessed the collaborate invitation I sent):
git clone https://github.com/jimskon/PhoneBookComplete
git clone https://github.com/jimskon/PhoneBookPython
Get it running. You will need to:
- Create your own version of the database.
- git clone the project PhoneBookComplete or PhoneBookPython
- Change the names (skon) in the software
- in Makefile change user to your username
- in the Javascript (phoneApp.js) change the cgi program name to your username:
$.ajax({ url: ‘/cgi-bin/skon_phoneAppComplete.cgi?deleteid=’+$(this).attr(‘ID’)+’&operation=delete’, - In PhoneBook.h or PhoneBook.py to change USER and DB to your username and PASS to your student ID
#define HOST “localhost”
#define USER “yourusername”
#define DB “yourusername”
#define PASS “yourmysqlpasssword” - (Optional, if you enable log files) In phoneApp.cpp or phoneApp.py change logfile name you your username.
- Add a PhoneBookComplete or PhoneBookPython directory to your web directory:
mkdir /var/www/html/class/softdev/username/PhoneAppComplete # for C++
mkdir /var/www/html/class/softdev/username/PhoneAppPython # for Python - If using Python, change path in phoneApp.py to your program directory, and make PhoneBook.py accessible from the web server:
sys.path.insert(1, ‘/home/skon/PhoneBookPython/’)
should change to:
sys.path.insert(1, ‘/home/student/yourusername/PhoneBookPython/’) - Type “make” to build and deploy your application
- Add the PhoneBook table to the your database (see next step):
Below is the structure of the database table you will need. You need to create a table named “PhoneBook” with the same fields and types, in you database:

Note the “AUTO_INCREMENT” for the ID field. This field is used as the unique ID for every row, and can be used for unambiguously referring to a record when changing or deleting. The “AUTO_INCREMENT” attribute assigns unique inter values for each record in a sequence. To do this click the “A_I” box for the field (you must scroll to the right to see it). This check box is available both then creating the table, and when editing the structure. For the type field you will need to add ‘Business’,’Friend’,’Family’,’Other’ to the values field.
Step 2 – Get the system to work with your database.
- Try out all the functions, make sure they work.
Turn in a link to your running application.
