#100DaysOfCode in Python Transcripts
Chapter: Days 97-99: Building JSON APIs
Lecture: Migrating our SQLAlchemy models

Login or purchase this course to watch this video and the rest of the course contents.
0:00 All right, it's time to move some existing code and data over here, just from our previous persistent Rock Paper Scissors.
0:09 Remember, one of the things that we used in the 15-way Rock Paper Scissors was we needed this CSV file to basically determine who wins and who loses
0:19 for any combination of those 15-way battles. Let's paste that over here. We're going to have our CSV file that tells us that,
0:28 and we'll also have this DB folder thing, we already saw that. This just tells us easy way to get back to this location
0:34 base and generate either read or writable files here. We're going to put our SQLAlchemy data in there as well.
0:41 That has to do with reading the data in the games. The other thing we had was lots of stuff around SQLAlchemy
0:46 defining the models and saving and querying who played a game, does the player exist, all of that stuff.
0:53 We're just going to take that and drop it in here. We're not really going to change that hardly at all.
1:00 But I'm going to make this folder called game_logic, and you can see we have our SQLAlchemy declarative base. We have our move.
1:07 This literally is the same thing as before. It's not changed at all. We have our game decider, our GameService. These are all basically the same.
1:15 I had to add just a couple of methods to GameService, but they're super trivial, like find a roll by id, and things like that.
1:21 Nothing important or new here, other than this only change really is that this game, it used to have all the loop logic and all that stuff,
1:32 and now we need to really separate that. That's going to go down into the client, but there's still a little bit of work that our game class
1:38 is going to do. We'll have this over here. There we've moved in the code from our game previously.
1:45 Now our job is to integrate it into our web application.

Talk Python's Mastodon Michael Kennedy's Mastodon