ITEC 3335
Database Development
Fall 2017
Homework #8

Embedded SQL

Write a simple Python program, h8q1.py, to connect to the database bigpvfc in dcm.uhcl.edu server to print out product information about a product line with number provided as the only command line argument. You must use PyMySQL driver for this assignment. For example:

C:\...>python h8q1.py 1
Products in Line #1:
--------------------
[Cherry End Table (id #1), finish: Cherry]:12 ordered.
[Birch Coffee Tables (id #2), finish: Birch]:30 ordered.
[Oak Computer Desk (id #3), finish: Oak]:24 ordered.
[Entertainment Center (id #4), finish: Cherry]:6 ordered.
[8-Drawer Dresser (id #6), finish: Birch]:7 ordered.
[Nightstand (id #13), finish: Cherry]:2 ordered.

C:\...>python h7q1.py 2
Products in Line #2:
--------------------
[Writer's Desk (id #5), finish: Oak]:13 ordered.
[Writer's Desk (id #14), finish: Birch]:12 ordered.
[Armoire (id #20), finish: Walnut]:1 ordered.


 Your program can use the file:

dbconfig.py:

import configparser

#  simplistic and no error handling.
def get_mysql_param(filename='dbconfig.ini', section='mysql'):

    config = configparser.ConfigParser()
    config.read(filename)

    return config['mysql']

 

This py program parses dbconfig.ini:

[mysql]
host = dcm.uhcl.edu
database = bigpvfc
user = ...
password = ...

Turn in a screenshot of the output and the python program h8q1.py. Your TA should be able to run your python program locally.

Submit the homework through Blackboard.