Coding against databases: Difference between revisions
(Created page with "{| width=500 style="float:right; margin-left: 10px; margin-top: -56px;" |Previous: MySQL |Next: Computer design |} == Material for the lesson == Note: The powerpoint has been updated with new library and transactions, but not the video.<br> Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=a891e09a-bec1-4ab1-8869-af2701258352 Using Python with MySQL]<br> Powerpoint: [https://teaching.healthtech.dtu.dk/material/36612/HPCLife13-CodingDB.ppt Coding with D...") |
No edit summary |
||
Line 6: | Line 6: | ||
Note: The powerpoint has been updated with new library and transactions, but not the video.<br> | Note: The powerpoint has been updated with new library and transactions, but not the video.<br> | ||
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=a891e09a-bec1-4ab1-8869-af2701258352 Using Python with MySQL]<br> | Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=a891e09a-bec1-4ab1-8869-af2701258352 Using Python with MySQL]<br> | ||
Powerpoint: [https://teaching.healthtech.dtu.dk/material/ | Powerpoint: [https://teaching.healthtech.dtu.dk/material/22112/HPCLife13-CodingDB.ppt Coding with Databases]<br> | ||
Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=68d743a1-9691-4690-b3a9-af170071ba0d Exercises] | Video: [https://panopto.dtu.dk/Panopto/Pages/Viewer.aspx?id=68d743a1-9691-4690-b3a9-af170071ba0d Exercises] | ||
Revision as of 11:50, 6 March 2024
Previous: MySQL | Next: Computer design |
Material for the lesson
Note: The powerpoint has been updated with new library and transactions, but not the video.
Video: Using Python with MySQL
Powerpoint: Coding with Databases
Video: Exercises
Exercises
Create one or two programs that can answer the following questions about the database you created last lesson. The data is from 2016 and all records are "complete" for the time period they were collected in. Specifically, all children's parents are in the database until we go so far back that records did not exists (the information is lost in the mists of time).
The programs should run on the server pupil1, not your own machine.
The mysql connect call looks like this.
cnx = mysql.connector.connect(user='DTUusername', passwd='YOUR_PASSWORD', db='DTUusername', host='localhost')
You can find your password in the .my.cnf file in your home.
You will mostly use python to solve the exercises. It is not intended that you use advanced mysql queries, but feel free.
Note, use this python: /home/ctools/anaconda3_2021.11/bin/python3
1)
Who are born out of wedlock? Definition: A child is born out of wedlock if the biological father and mother is not married when the child is born. In the absence of information, you can not claim a child is born out of wedlock (that means if you only know the mother from the database, you can not claim the child is a bastard).
2)
Are there families who have had the same disease through 3 generations? Who and what disease in such case? It is not a trick question - you will find some.
In answering this question, then any type of cancer should just be regarded as cancer, i.e. the same disease (this is not true in reality). 3 generations should be understood as a ”straight line of inheritance”, i.e. child, father, father’s father/mother. Child, mother and father’s father is not straight.
If you look closely at your results, you will find some very interesting family patterns - such is the curse of (badly) generated data.