Here are pictures of diagrams and spreadsheets that we created in class
Wednesday, January 9, 2019
Setup and Configure Django --steps
The first two assignments involved a lot of steps, so I though it might be useful to list them. Most of these steps only need to be done once. Also I want to reiterate that the tech review project and app are the in-class examples, the assignments are all with the python club project and app.
Initial set up
- Create a directory for the django projects
- Install django into that directory
- Install venv, the virtual environment
- Activate the virtual environment
- Create the project techreviews
- change directory into techreviews and start the app tech
- (do the same two steps with pythonclub)
Configuration
- Create the techreviewdb in pgadmin (also create pythonclubdb)
- Open VSCode, Open a folder to the outermost techteview folder
- Also open a terminal in VSCode
- Open the settings.py file in the project folder.
- In the settings.py file add 'tech' to the registered apps list.
- Also in the settings.py change the database to postgresql_psycopg2.
- You will need to install psycopg2 using pip, using the terminal in VSCode
- Migrate the databases
- In the project lever urls.py add an include that points to the app's url
- Add a urls.py file to the app directory
At this point you will have completed the setup and configuration
Tuesday, January 8, 2019
Selects
--Selects Select * From Person; -- this takes more processing time since it will need to figure out what all the columns are Select personlastname, personfirstname, personemail -- this will run faster since columns are specified From Person; Select personfirstname As "First Name", --you can use "as" to label your output table columns personlastname As "Last Name", personemail As "Email" From Person; Select personkey, personfirstname, personlastname, personemail From Person order by personlastname, personfirstname Desc; select * From donation where personkey = 6; Select * From personaddress Where personaddresscity = 'Bellevue'; -- not typically case sensitive but ours is Select * From personaddress Where NOT personaddresscity = 'Seattle'; Select personkey, personaddressstreet, personaddressapt From personaddress Where personaddressapt is null OR personaddressapt = ' '; Select personaddressstreet, personaddressapt From Personaddress Where personaddressapt is null or personaddressapt=''; --11 Select personaddressstreet, personaddressapt From Personaddress Where personaddressapt is not null; Select personaddressstreet, personaddressapt From Personaddress Where personaddressapt = null; Select * from Donation; Select * from donation where donationamount >1000 order by donationamount desc; Select * from donation where donationamount between 1000 and 1500 order by donationamount desc; Select * from donation where donationdate between '2017-06-01' And '2017-07-31'; Select * from donation where donationamount <= 1000; Insert into donation (personkey, donationamount, donationdate) Values (6, 500, current_timestamp); Select * from donation where donationdate = '2019-01-08'; Select Personfirstname, personlastname from person where personlastname like 'L%n'; Select Personfirstname, personlastname from person where personlastname like 'Car_l'; --Distinct Select distinct personkey from donation order by personkey;
Monday, January 7, 2019
Database Notes
Process
How know you need a database?
The amount of data
Current methods no longer work
Talk to people who need the database
Not too technichal
Really general requirements
Vince's Vinyl used record store
Interview with management
Why do you need a database? What information do you need to keep?
How do want to enter data? How are you doing it now?
Inventory, Sales (discounts), Customer--requests, purchases, Employees, who purchased from
Who will use the database? Limits, Permissions
Statement Of Scopeinformation discovery
Forms --receipts sales and purchase, notebook, requests
Reports--reports- tax statements, monthly and yearly earnings
manuals, procedures
Job shadowing--you watch how people do the job. finding exceptions.
Interview stakeholders
Review--look at all the nouns
Inventory --quality (good fair poor mint) title, genre(s), artist(s), playtime, edition, print year, who purchased, (songs) quantity, purchasedate, purchaseprice, Suggest sale price, location, requested, availablity,
Customer Name, contact info, phonenumber email, purchase history, requests, membership status, discounts, store credit, perferences
Sale customer, date of sale, employee, sale price, inventory item(s) sold tax, discounts, (profit--don't store calculated fields)
request Customer, condition, Album requested--artist requesting, price range, date requested, data fulfilled
Employees name, datehired, position, sales, address, phone, email
Purchase (store purchasing) item names, quality, purchase date, price paid, edition, vender,
Tuesday, December 4, 2018
Assignment 8. Grades
grade.py
class Grade(): def __init__(self, course, credits, score): self.course=course self.credits=credits self.score=score def getCourse(self): return self.course def getCredits(self): return self.credits def getScore(self): return self.score
Student.py
from grade import Grade class Student(): def __init__(self, SID, name, email): self.SID =SID self.name=name self.email=email self.grades=[] def getSID(self): return self.SID def getName(self): return self.name def getEmail(self): return self.email def addGrade(self,grade): self.grades.append(grade) def getGrades(self): return self.grades def calculateGPA(self): totalCredits=0.0 totalWeight=0.0 gpa=0.0 if len(self.grades) != 0: for i in range(len(self.grades)): totalCredits += self.grades[i].credits totalWeight += self.grades[i].credits * self.grades[i].score gpa = totalWeight / totalCredits return gpa def __str__(self): return self.SID + " " + self.name + " " + self.email
StudentDisplay.py
from grade import Grade from student import Student class Display(): def __init__(self): self.makeStudent() self.enterGrades() self.outputStuff() def makeStudent(self): sid = input("Enter the student SID ") name= input(" Enter the student name ") email=input("Enter the student emai ") self.student = Student(sid,name,email) def enterGrades(self): done='n' while done == 'n': course=input("Enter the course name ") credits=float(input("Enter the number of credits ")) finalGrade=float(input("Enter the final grade ")) self.grade =Grade(course, credits, finalGrade) self.student.addGrade(self.grade) done = input("Done n. y to quit ") done=done.lower() def outputStuff(self): print(self.student) gradeList=self.student.getGrades() for i in range(len(gradeList)): print(gradeList[i].course, gradeList[i].credits, gradeList[i].score) gpa = self.student.calculateGPA() print ("The GPA is ", gpa) def main(): display=Display() main()
Wednesday, November 28, 2018
Show Tracker JSON Afternoon
{
name :'Triple Door',
address : '216 Union street, Seattle ',
restrictions : 'sometimes',
parking : 'bus recommended',
url : 'http://www.triple.net',
email : 'tripledoor@gmail.com ',
phone : '2065551234',
description : 'restaurant and music lounge'
}
{
name : 'An intimate evening',
venue : {name:'Triple Door ', url : 'http://www.triple.net'},
artists : [{name: 'The Paper Boys', genre: 'Jazz'},
{name : 'Mitzki', genre: ['alt rock', 'folk']}],
datetime : ISODate('2018-12-07T20:00:00'),
price : [{type: 'general', cost : 80.00},
{type : 'VIP', cost : 120.00} ],
}
[{
fanname : 'showgoer ',
email : 'showgoer@gmail.com ',
artists: ['Death Cab For Cutie','Imagine Dragons' ],
genres : ['alt rock', 'pop' ]
},
{
fanname : 'neversaydie ',
email : 'nsd@msn.com',
artists: ['Mitzki','Bob Dylan'],
genres : ['alt rock', 'folk' ]
}]
show tracker JSON
{
name: 'Deck The Hall Ball',
date : ISODate('2018-12-11T17:00:00'),
artist : [{name: 'Death Cab for Cutie', genre : 'alt rock'},
{name: 'Billie Eilish', genre : 'alt rock'},
{name: 'Young the Giant', genre : 'alt rock'}],
price : [{type: 'general', amount : 60.00},
{type: 'reserved', amount : 80.00}],
venue : {name : 'WaMu Theater',
address : '800 Occidental Ave,South',
URL : 'http://centrylink.com'},
restrictions : 'no food, no drinks',
parking : 'On site parking. Next to light rail'
}
[{
username : 'showgoer',
email : 'showgoer@gmail.com',
artists : ['Death cab for Cutie', 'Neil Young', 'Lorde'],
genres : ['alt rock', 'rock', 'folk']
},
{
username : 'readytorock',
email : 'rtor@msn.com',
artists : ['Metalica', 'Iron Maiden', 'Black Sabbath']
}]
Two more shows
[{
name : 'Deck the Hall Ball',
venue : {name:'WaMu Theater', url : 'http://www.WaMu.com'},
artists : [{name: 'Death Cab for Cutie', genre: ['alt','pop']},
{name : 'Billie Eilish', genre: ['alt rock', 'pop']}],
datetime : ISODate('2018-12-11T20:00:00'),
price : [{type: 'general', cost : 80.00},
{type : 'VIP', cost : 120.00} ],
},
{
name : 'Bob Dylan',
venue : {name:'Paramount', url : 'http://www.Paramount.com'},
artists : {name: 'Bob Dylan', genre: ['rock', 'folk']},
datetime : ISODate('2019-02-07T20:00:00'),
price : [{type: 'general', cost : 80.00},
{type : 'VIP', cost : 120.00} ],
}]
Two more fans
[{
fanname : 'superfan',
email : 'superfan@gmail.com ',
artists: ['Death Cab For Cutie','Billie Eilsih' ],
genres : ['alt rock', 'pop' ]
},
{
fanname : 'concertgoer ',
email : 'concertgoer@msn.com',
artists: ['Mitzki','Bob Dylan', 'Neil Young'],
genres : ['alt rock', 'folk' ]
}]