Supabase database questions and answers
Answering the frontend-focused Supabase database questions.
Answering the frontend-focused Supabase database questions.
Supabase is a Backend-as-a-Service (BaaS) platform that is almost entirely open source, which provides flexibility for developers. While their hosted service is what most people use, you have the freedom to self-host the entire stack. This open-source nature is a key differentiator when comparing it to other solutions like a custom stack with Hasura.
When you're diving into Python's Object-Oriented Programming (OOP) features, decorators like @property and @classmethod pop up all the time. They might seem similar at first glance, but they serve fundamentally different purposes. Getting them straight is key to writing clean, Pythonic code.
Let's cut through the noise and get straight to what they do and when you should use them.
As a Django app grows, managing database queries effectively is crucial for maintainability, performance, and testability. Storing them haphazardly is a recipe for disaster. The best place to store your queries is on custom Model Managers and QuerySets. This approach keeps your logic organized, reusable, and closely tied to the data it operates on. Here are the main variants for storing your queries, from the least recommended to the best practice.
If you're at a point where you want to build a site that goes beyond just a portfolio or a blog-something you might monetize, track analytics on, add dynamic features to, or even scale up into something bigger-it’s important to choose your hosting platform wisely. GitHub Pages and Vercel are both wildly popular options, but they offer fundamentally different experiences once you want to do more than just put HTML online.
Typing that boilerplate from scratch every time is not only tedious, but also error-prone. Fortunately, if you're using Visual Studio Code, there are excellent ways to automate this process by creating custom templates or snippets. Let's walk through some effective strategies for doing just that.
Sometimes even the simplest programs deserve solid testing-especially when you're working in a team or trying to set strong standards for code quality. In this note, we'll take the most basic example-"Hello, World!"-and build out everything around it to demonstrate how doctests can be used effectively, even for something so trivial. The goal is to build intuition for testing, not just solve a toy problem.
Doctest is a module in the Python Standard Library that enables you to write tests within the documentation of your code-typically inside docstrings. These tests look like interactive Python sessions (as if they were run in a Python shell), and the doctest module verifies that the output matches the expected result. While doctests are generally simpler than unit tests written with unittest or pytest, they are powerful for checking that code examples in documentation remain correct over time.
This guide explores the various ways to execute doctests in Python, from running them via the command line to embedding them in code and running them programmatically.
So I’ve been thinking lately about testing strategies again, and one question came up that I kept circling back to: does every function in my Python codebase need to have a doctest?
If you're writing doctests in Python using Gitpod or VS Code, you don’t need much to get started. Python’s built-in doctest module lets you write examples in your function’s docstring using the familiar >>> prompt, and then run those examples as tests. This is great for small, focused functions or when you want your documentation to double as lightweight tests.