Chapter 1 - Building a Backend with SeaORM

Full source code available on GitHub.

In this chapter, we will build a backend application with SeaORM. It will act as a layer of communication with the database.

The application will simulate the interface of a database of bakeries. For simplicity, there will be only two entities, Bakery and Baker. We will explore the schema later on.

Choosing a Database

Before we start building the backend, we want to make sure that the database is up and running. Setting up the database is beyond the scope of this tutorial.

SeaORM itself is agnostic to different database implementations, including MySQL, PostgreSQL, and SQLite (in files or in memory).

However, depending on the database of your choice, you need to pay attention to the following:

  • The appropriate DB driver feature should be enabled.
  • A valid database URL should be used:
DatabaseExample Database URL
SQLite (in file)sqlite:./sqlite.db?mode=rwc
SQLite (in memory)sqlite::memory:

We will showcase exactly how to and where to use them in the next section.

Once the database is ready, we can proceed to set up the project.