Phase 3 sql, tuples, and object problems

Hello, my name is Daniel Trejo and I’m a student at Flatiron School in the Software Engineering program. Phase 3 was definitely the hardest one yet because of the sheer amount of curriculum. The hardest part for me was the project which is probably not surprising due to the fact that it is the final project of the phase. However I ran into a ton of issues right off the bat but once I got started it wasn’t actually that bad. That was until I finished it. Now you might be saying, “It’s being done a good thing?” Normally yes but with coding, finishing coding doesn’t always mean the project is done.

Now I ran into a heap of issues at this point and they were are super simple fixes except for one. I needed get some data to display at the end of another piece of data but these 2 pieces of data are from different places. Now to some people that might be a simple fix but to me who has been struggling a lot recently with personal stuff and just the scope of the phase. It took me until doing the project to even start completely understanding python, cli, orm, and sql as is.

The problem was I wasn’t grabbing the information correctly so I had to create a whole new function and test run for hours trying to get the right thing. Once I finally did, I was so happy but that was until I ran into another problem.

I needed it to return an object but all it kept returning was a tuple. Which meant the information I was getting wasn’t returning at all. That’s when I found out through using one of the best tools in python,

breakpoint()

that it WAS returning something and it was a tuple but my program didn’t know what to do with that tuple. It wasn’t actually showing anything on the return until I grabbed the index of that information with [0] brackets. Yay finally it was fixed, however, what everyone will deal with after fixing something. Another problem popped up. It was that I was returning everything as a tuple which meant as a string. A requirement of the project was to be able to view related object. I was viewing just the string of what I needed which isn’t an object. So that’s when I figured out that I needed to return an object not a tuple. Instead of using sql like this,

sql = """ SELECT name FROM authors WHERE id = ? """ 
Enter fullscreen mode
Exit fullscreen mode

I had to use it like this,

sql = """ SELECT * FROM authors WHERE id = ? """
Enter fullscreen mode
Exit fullscreen mode

The first way was just grabbing the string(name) instead of grabbing the whole object, which the second version did. Then I had to call it in my repr as self.author().name because doing .name is one of the 2 ways to grab something from an object.


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Pa46 350t matrix initial training courses pa46 350t matrix recurrent training courses.