---
# System prepended metadata

title: Lab2d - Leo and Ben

---

# Lab2d - Leo and Ben 
## October 31, 2022

## Order to run files:
In order to test our interface, we ask that you run our files in the following order:

tables.sql -> triggers.sql -> procedures.sql -> lab2d.py

And we also ask that you ensure that lab2d_config.py and Team20Lab2.ini are in the same folder as lab2d.py to allow for smooth connection and password insertion.

**NOTE**: We did not include certain files like view.sql or triggertest.sql from lab2c because they are unnecessary in running lab2d. Similarlly, we did not include a bash or make file since these are also unnecessary in our case. 

## Description:
This final section of lab2 is the front end of the application that connects to the database. Input is taken from stdin and relevant information such as userid and status is outputted to stdout for use by user.

Based on the example python files provided for us, we created an additional stdin command "exit" that gracefully exits you out of your SQL connection by closing connection rather than simply killing the terminal. 

## Assumptions
1. Filename in manuscript submission is unique.
2. Pages of manuscript is randomly generated to be between 1 and 60 pages to allow for insertion.
3. Each individual is a unique person with a unique first and last name.
4. If a co-author for a give manuscript decides to become a primary author, they will be given another unique id to allow access to author commands. 
5. Case where reviewer resigns is handled in python file instead of sql trigger due to changes in database implementation from part 2c to 2d.
6. For all commands that could contain multiple words for instance affiliation they are written with quotes (i.e., "Dartmouth College"). 
7. All output from stdin commands will only be printed to the terminal and not returned.
8. Editor will not publish an issue until it is ready and will ensure that the pages filled are between 75 and 100.
9. Editor will follow the constraints set by the journal. Meaning if the cut-off score for acceptance of a manuscript is 40, all manuscripts with average score below 40 will be rejected and all above will be accepted.
10. We assume that the grader/user expects a fresh database at the start of every run of the python file and thus the datbase is reset at the beginning of the file.

## Files:
#### tables.sql -- create tables in database based on E/R diagram
#### views.sql -- contains views created in lab2c (not used in part d)
#### lab2d_dbconfig.py -- holds function to read configuarion file
#### ICodes.sql -- Holds icode table
#### triggers.sql -- holds 3 triggers to check (a) if there are enough reviewers, (b) update feedback and assignment if a reveiewer resigns, and \(c\) puts a accepted manuscript into typesetting mode
#### procedures.sql -- created SQL function that compares a manuscripts average score to jounral cut-off and returns whether accepted or rejected
#### lab2d.py -- python file to run for frontend in terminal. Standard in is used to take commands from user, which then calls functions based on user type (editor, author, reviewer)
#### Team20Lab2.ini -- configuration for access to mysql database