Anvil: Web Apps with Nothing but Python Transcripts
Chapter: Databases: Storing and querying data
Lecture: Concept: Data tables

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's review really quick. So, we saw that we have a database system already built into Anvil.
0:07 All we have to do is go and enable the data table's service. We saw, in our case, that actually was already done
0:14 or as someone created the user management stuff but it could be that you create the tables first before you do that, and you have to add it explicitly.
0:22 So here we have a couple of tables that we've created averages and measurements, and one called users that was the one created by the user service.
0:31 And you can see that we've added a record date created date, weight in pounds, resting heart rate. Those are standard columns, just direct data
0:39 dates, date times, numbers, and so on. But we also had a foreign key relationship over to the user. This is the user to whom those measurements belong
0:49 and those have a little bit different hyperlink-y looking thing here. You saw you can even click it and pull up details from the user table.
0:55 That's pretty awesome. The other thing we have to look at is the security. By default, these are not accessible
1:01 and probably should never be writable from Javascript. I don't know, that seems like a reasonable statement.
1:08 We have the forms, that is, the client side Javascript cannot directly access this table at all. However, the server-side modules
1:17 which are run on the server and are protected they can do the validation they need and then do whatever they want to talk to the database.
1:22 So we had a server-side module that did two things. Added these records here and then we query 'em for the given logged in user. That's data tables.


Talk Python's Mastodon Michael Kennedy's Mastodon