Friday, November 29, 2019

How to use CockroachDB Community Edition with Django and Multipass on OSX

Over the break, I wrote a short tutorial on using CockroachDB with Django. This is a slight derivative of
that post using Multipass and community edition of CockroachDB. It means it does not require a license
and is missing RBAC features but for the purposes of the tutorial, all features of CockroachDB will be
present.

Since the original tutorial was based on Ubuntu, I decided to use Multipass as it allows me to spin up
Ubuntu instances quickly on my Mac. Binaries for multipass are available for Windows and Linux as well.
Granted same can be achieved with a virtual machine, docker container or a Vagrant environment,
I chose to give this a spin as I was not familiar with the tool.

Documentation on installing cockroach can be found at the following link. The video below depicts
the process in two steps but once you're inside multipass shell, you can follow the instructions as
advertised and download the binary as well as uncompressing it in one step.

For the purposes of brevity, I will only highlight the new commands, for everything else, the original
tutorial and my previous tutorial can be followed as is.



How to Use CockroachDB with your Django Application


This is a short tutorial on using Django with CockroachDB. This tutorial is intended to be a quick ramp

up on CockroachDB with Django, in case you're searching for a proper Django tutorial, this is not it.
At the time of writing, django-cockroachdb library is available in two versions, (2 and 3). This post
focuses on version 2 specifically. This tutorial is based on the Digital Ocean tutorial using Django with
PostgreSQL. I am going to highlight the steps where this tutorial differs from the original. For everything
else, we will assume the tutorial is followed as is. Since we’re going to need RBAC features of
CockroachDB, we will require an enterprise license, feel free to request a trial or try this tutorial with
cockroach demo environment where enterprise features are enabled for 60 minutes, which is plenty to
complete this tutorial.