Python Day 48 – the roller coaster of SQL

I started off the day very frustrated. The smallest syntax errors were messing me up. I learned the hard way to always put a comma after SELECTing a category in SQL, and to make sure to put a backslash if I’m separating lines. After these initial frustrations I was almost ready to put the computer away. But then I said to myself, why don’t I try one practice problem? And to my surprise I found myself actually understanding the problem!! Before I knew it I was through 8 problems in a row with only a little bit of struggle.

That was so exhilarating. The third to last question unfortunately brought my ego back down to Earth as I was forced to think about JOINing tables together. This was most unfortunate. I still haven’t been able to crack this one. I was able to properly join the data I want, however I’m confused on where to put certain SQL commands now. GROUP BY and ORDER BY seem to work where they are, but the command WHERE is not working wherever I put it.

This shall be a problem to solve tomorrow. Other than this, the only other part I’m confused on is the initial setup for getting code into Python. I’ve been taught to use this code:

cur = conn.cursor()
query = “SELECT * FROM sqlite_master WHERE type = ‘table’;”
results = cur.execute(query).fetchall()

… but I’m not sure what it does (specifically .cursor()) yet.

Alas. Today has been a good day 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: