If you call yourself a builder, whether that means working on a startup, open source, or personal projects, you need to keep up to date with the latest tech. Innovation in software development is only accelerating, with paradigm shifts happening more and more often.
In the world of Databases, FaundaDB has generated a lot of buzz by creating one of the most versatile, scalable, and intuitive database technologies out there.
Today, we’ll explore how FaunaDB works and create and use our first Fauna database.
What is FaunaDB?
Fauna is a serverless, multi-region database that is accessible through a cloud API. That means that Creating, Reading, Updating and Deleting data can all be done within a standard api call.
For the more technically minded, Fauna is what’s called a transactional database. In layman’s terms, this means that you can get the flexibility of a noSQL database like Mongo, without sacrificing the speed and accuracy you get from a SQL Database.
This makes Fauna an amazing option for startups and personal projects that want to build quickly without incurring a ton of technical debt.
Creating a FaunaDB Account
To get started, first visit the signup page and create a free fauna account. This will direct the user to the fauna dashboard.
Click on CREATE DATABASE to create a database. Next, provide the database name and the region where the database will be created.
We will need the access key to interact with the database. Navigate to the security section from the database view. Here, you can create the access key that will be used to communicate with the Fauna API.
Integrating FaunaDB with an Application
Now that we have created a Fauna database and obtained the access key, we can utilize FaunaDB in an application. In this section, we will look at how we can communicate with FaunaDB using Python. Of course, since this is all API based, implementations will be nearly identical in every language.
Let’s first setup a python environment with:
Now let’s install the dependencies. This is the Python driver for FaunaDB.
Pipenv install faunadb
Create the Application
In the following code, we connect to our database and perform all four CRUD operations that we expect from a database:
If the program is successfully executed, you should see the following output for each respective function:
There you have it! We’ve setup our own FaunaDB project and performed all the standard database technologies in less than 100 lines of code. The simplicity of this implementation isn’t a result of us cutting corners – it’s actually that easy!
So what do you think? Are you going to be using FaunaDB for your next project? Let us know down below!
Happy coding from your good friends at Codesphere, the swiss army knife every software developer needs.