Contents:
Progress Report
Bug Report
Surf Report
Tweet Report
Progress Report
And just like that, week 4 at Rithm is in the can—it's been another great week of learning. We continued to focus on the backend, but this week, our primary focus was on databases and how to interact with them using SQLAlchemy in our Flask applications.
Databases and SQL
We started the week by learning the basics of SQL (Structured Query Language) and how to interact with relational databases using SQL queries. We practiced creating tables, inserting data, updating records, and querying the data using various conditions.
SQLAlchemy
Once we had a firm grasp of SQL, we moved on to learn SQLAlchemy, a powerful Python ORM (Object Relational Mapper) that makes it easier to interact with databases in a more Pythonic way. We learned how to create models, define relationships between tables, and perform CRUD operations without having to write raw SQL queries.
Using SQLAlchemy in our Flask applications made it much easier to manage the data and keep our code clean and organized. It also helped us maintain a consistent structure across our projects.
Next week is our final week in Python, and we’re diving into security, authorization, and cryptography! Onward!
Bug Report
This week's bug was related to the relationships between tables in our database. We were working on a blog application where users can create posts and leave comments on them.
We defined two models, User
and Post
, and created a one-to-many relationship between them, where a user can have many posts but each post belongs to one user.
We also defined another model, Comment
, and created a one-to-many relationship between Post
and Comment
.
The bug occurred when we tried to retrieve all the comments associated with a specific post. We were expecting the comments to be sorted by their creation time, but they were returned in a seemingly random order.
After a bit of debugging, we realized that we forgot to define an order_by attribute for the relationship between Post
and Comment
. By default, SQLAlchemy doesn't order the related records unless explicitly specified.
To fix the issue, we modified the relationship definition in the Post
model as follows:
class Post(db.Model):
# ...
comments = db.relationship('Comment', backref='post', order_by='Comment.created_at')
# ...
With this change, SQLAlchemy now orders the related comments by their creation time, as we originally intended.
Surf Report
Seeking Cerebral Valley: A Photographic Tour of San Francisco’s AI Underground (The Information)
SF’s Central Subway saw declines in ridership during its first two months of service, data show (SF Chronicle)
GPT-4 was released (Open AI)
Midjourney v5 was released (Midjourney via Twitter)
Tweet Report
Dan Shipper highlights four ways to leverage GPT-4 to be an excellent writing partner.
Nick St. Pierre knocks it out of the park with another stunning piece of AI-generated content. This time, a fully blown 30-second video written, directed, and shot (almost) entirely using various AI tools. The future is now!