Software Development

General software development principals and tools. Receive insights applicable to building any application.
Constructing Database Queries with SQLAlchemy

Constructing Database Queries with SQLAlchemy

Query your data models using SQLAlchemy's query API.

So far in our SQLAlchemy journey, we've covered managing database connections and model creation. So... how do we actually extract the data we want from our database?

SQLAlchemy's ORM query API simplifies the way we write database queries. Instead of writing raw SQL queries, we can construct queries on our SQLAlchemy session by chaining together methods to retrieve data. We're going to dive into SQLAlchemy's extensive query API to get an idea of all the ways we can query our data.

This tutorial will assume you know how to create an SQLAlchemy session. We'll also assume you have some data

Managing Relationships in SQLAlchemy Data Models

Managing Relationships in SQLAlchemy Data Models

Using the SQLAlchemy ORM to build data models with meaningful relationships.

There are plenty of good reasons to use SQLAlchemy, from managing database connections to easy integrations with libraries such as Pandas. If you're in the app-building business, I'd be willing to bet that managing your app's data via an ORM is at the top of your list of use cases for SQLAlchemy.

Most software engineers likely find database model management to be easier than SQL queries. For people with heavy data backgrounds (like us), the added abstractions can be a bit off-putting: why do we need foreign keys to execute JOINs between two tables? Why do we need to distinguish

Managing Flask Session Variables

Managing Flask Session Variables

Using Flask-Session and Flask-Redis to store user session variables.

When building we build applications that handle users, a lot of functionality depends on storing session variables for users. Consider a typical checkout cart: it's quite often that an abandoned cart on any e-commerce website will retain its contents long after a user abandons. Carts sometimes even have their contents persist across devices! To build such functionality, we cannot rely on Flask's default method of storing session variables, which happens via locally stored browser cookies. Instead, we can use a cloud key/value store such as Redis, and leverage a plugin called Flask-Session.

Flask-Session is a Flask plugin which enables

Getting Started With Wagtail CMS

Getting Started With Wagtail CMS

Setting up Wagtail CMS: The cleanest and friendliest CMS available for Django

Last time we spoke of Django, we installed Django CMS: perhaps the most popular out-of-the-box CMS available for Django. Now that we've explored the most popular CMS, let's move on to the best CMS.

I realize I'm speaking of something subjective as though it were fact. As much as I'd like to agree that this is wrong, doing so would make for a boring read. I'll stick to my guns here.

Installing Wagtail

To makes things easy, we'll start with the obligatory server updates and Python3 setup. This way, the copy-and-paste crew will have no problem following along. It's important

Using Flask-Login to Handle User Accounts

Using Flask-Login to Handle User Accounts

Add user authentication to your Flask app with Flask-Login

We’ve covered a lot of Flask goodness in this series thus far. We fully understand how to structure a sensible application; we can serve up complex page templates, and have dived into interacting with databases using Flask-SQLAlchemy. For our next challenge, we’re going to need all of the knowledge we've acquired thus far and much, much more. Welcome to the Super Bowl of Flask development. This. Is. Flask-Login.

Flask-Login is a dope library which handles all aspects of user management, including vital nuances you might not expect. Some noteworthy features include securing parts of our app behind login

Working With GraphQL Fragments and Mutations

Working With GraphQL Fragments and Mutations

Make your GraphQL queries more dynamic with Fragments, plus get started with Mutations.

Last week we encountered a genuine scenario when working with GraphQL clients. When building real applications consuming data via GraphQL, we usually don't know precisely the query we're going to want to run at runtime. Imagine a user cruising through your application, setting preferences, and arriving at core pieces of functionality under a content which is specific only to them. Say we're building a GrubHub knockoff (we hate profits and love entering impenetrable parts of the market, it's not that uncommon really.) At its core, the information we're serving will always be restaurants; we'll always want to return things like

Serve Docker Containers With A Custom Domain and SSL

Serve Docker Containers With A Custom Domain and SSL

Do even less work to deploy your Docker apps to production.

The past few years of software development and architecture has witnessed multiple revolutions. The rise of containers, unruly package management ecosystems, and one-click-deployments holds an unspoken narrative: most people probably don’t care about how things work beneath the top layer. Sure, advancements in application infrastructure has undoubtedly made our lives easier. I suppose I find this lack of curiosity and unwillingness to dig deeper into the innards, an unrelatable trait. Yet I digress.

I’ve never found web server configurations to be particularly difficult, but apparently most consider this enough of a nuisance to make something even easier to

Building a Client For Your GraphQL API

Building a Client For Your GraphQL API

Now that we have an understanding of GraphQL queries and API setup, it's time to get that data.

If you had the pleasure of joining us last time, we had just completed a crash course in structuring GraphQL Queries. As much we all love studying abstract queries within the confines of a playground environment, the only real way to learn anything to overzealously attempt to build something way out of our skill level. Thus, we're going to shift gears and actually make something with all the dry technical knowledge we've accumulated so far. Hooray!

Data Gone Wild: Exposing Your GraphQL Endpoint

If you're following along with Prisma as your GraphQL service, the endpoint for your API defaults to

Writing Your First GraphQL Query

Writing Your First GraphQL Query

Begin to structure complex queries against your GraphQL API.

In our last run-in with GraphQL, we used Prisma to assist in setting up a GraphQL server. This effectively gave us an endpoint to work with for making GraphQL requests against the database we specified when getting started. If you're still in the business of setting up a GraphQL server, there are plenty of alternative services to Prisma you could explore. Apollo is perhaps the most popular. A different approach could be to use GraphCMS: a headless CMS for building GraphQL models with a beautiful interface.

With our first models are created and deployed, we’re now able to explore

Manage Database Models with Flask-SQLAlchemy

Manage Database Models with Flask-SQLAlchemy

Connect your Flask app to a database using Flask-SQLAlchemy.

By now you're surely familiar with the benefits of Python's SQLAlchemy library: the all-in-one solution for basically anything database related. Like most major Python libraries, SQLAlchemy has been ported into a version specifically compatible with Flask, aptly named Flask-SQLAlchemy.

Similar to the core SQLAlchemy package, Flask-SQLAlchemy provides an ORM for us to modify application data by easily creating defined models. Regardless of what your database of choice might be, Flask-SQLAlchemy will ensure that the models we create in Python will translate to the syntax of our chosen database. Given the ease-of-use and one-size-fits-all  nature of Flask-SQLAlchemy, it's no wonder that

Poetically Packaging Your Python Project

Poetically Packaging Your Python Project

Manage your projects with Poetry to handle dependencies, envs, packaging, etc.

It wasn't long ago that we Hackers were singing the praises of Pipenv: Python's seemingly superior dependency manager at the time. While we hold much love in hearts, sometimes there is love to go around. We just so happen to be fair weather fans, which reminds me: what has Pipenv done for me lately?

As you've probably guessed (considering its a piece of software), nothing much. Well, there was that time when pip upgraded from v.18 to v.18.1, which broke Pipenv entirely with almost minimal acknowledgment (for all I know this might still be broken). As our

Using Redis to Store Information in Python Applications

Using Redis to Store Information in Python Applications

A temporary data store for everything from session variables to chat queues.

We’re hacking into the new year here at Hackers and Slackers, and in the process, we’ve received plenty of new gifts to play with. Nevermind how Santa manages to fit physically non-existent SaaS products under the Christmas tree. We ask for abstract enterprise software every year, and this time we happened to get a little red box.

If you've never personally used Redis, the name probably sounds familiar as you've been bombarded with obscure technology brand names in places like the Heroku marketplace, or your unacceptably nerdy Twitter account (I assure you, mine is worse). So what is

Integrate Plotly Dash Into Your Flask App

Integrate Plotly Dash Into Your Flask App

Crack full control over Plotly Dash by hacking an integration with Flask.

Ahh, Plotly. Typing that name into a post headline triggers an emotional cocktail of both pride and embarrassment. Plotly has been at the core of some of the most influential products I’ve personally worked on over the years: a jumble of Fintech and humanitarian clients, all of which are still proudly waving their charts and dashboards around the world. Yet, my mind is boggled by a simple question: what the hell took us so long to write our first post about Plotly? We've been operating Hackers and Slackers for over a full year now... did I seriously write a

Demystifying Flask’s Application Factory

Demystifying Flask’s Application Factory

Breaking down the nuances of creating a Flask application correctly.

A 'skill' that's always fascinated me is just how long some engineers can make it in their career while carrying glaringly obvious gaps in their knowledge of the systems they use every day. To my surprise, I've turned corners where I have been that engineer all along, and there's perhaps no better example of this then the time I've spent with Flask.

WARNING: highly opinionated statement incoming: Flask is everything a framework should be. /opinion. That is to say, it isn't really a fully-fledged framework at all. Sure, the term microframework might seem like a cute branding term, but that