Tuesday, November 4, 2014

Project Day 2, part 2

Katie, my lovely advisor, said to keep a journal, so I'm going to update this blog a lot over the next few weeks.

After getting my database read in and walking around a lot, I tackled writing a controller script so I can eventually add recipes to what I have right now.

To start, I decided to see if I could even get information from my databases. First up was getting the user name from the list of users based on a user ID... check! Got that one in one go. SQLAlchemy with a get (user_id) request. And I hard-coded my user_id... eventually, that will be part of the log in.

Next up was getting a list of recipes submitted by that user (this will help when I get the user specific page going). Well, this one took a bit more doing, but it was essentially an SQLAlchemy request with an "all()" request. Also, I wanted to show off what the names were, not an ID that wouldn't give anyone any info. Well, got that one going pretty well and pretty easily.

Step 3, get the components of each recipe. This one took a bit of doing because the chemical names were referenced as an id in the components. So, I had to start writing the getComponents function. Stop. And then write the getChemicalNameByID function.

Also, I had to stop and adjust my variable names... too many "user_id" variables running about. So, the ones in the controller script because "userID" or "chemID" and what not.

After a few boo boos, where I was getting the wrong names (yes, there's a difference between comp.id and comp.chem_id... one is the component ID number and the other is the component chemical id... totally different numbers!

Well, once I got that fixed, I was able to go back and get the getComponents function to work and now my controller script is happy!

BUT... not done yet haha. I need to see how to add a new recipe. Which is a pain in the ass. I mean. It's easy to add a new recipe because it only has the attributes of id, user_id and recipe_name. But, getting the right components in there is going to be the fun part.

First up, get chem_id from chem_name... Functions are fun!

No comments:

Post a Comment