liveBook · Manning

PostgreSQL

As explained in Rust Servers, Services, and Apps

Postgres is an open-source object-relational database management system.

PostgreSQL, commonly called Postgres, is an open-source relational database used to persist application data. In a Rust web application, it stores courses durably instead of losing them when the service restarts. section 4.2.1 section 4.0

A practical integration pairs Postgres with SQLx, which sends raw SQL, checks queries at compile time, provides a connection pool, and exposes asynchronous database connections. This fits an asynchronous Actix Web service because the service can continue other work while waiting for database responses. section 4.2.1 section 1.3.1

Set up and exercise a database-backed Rust service in these steps:

  • Install Postgres, create the ezytutors database and a database user, then grant that user access. section 4.2.2
  • Define a course table with serial identifiers, required tutor and name fields, a timestamp default, and seed records. section 4.2.2
  • Configure DATABASE_URL, create a PgPool in Rust, run a parameterized query, and display the returned course rows. section 4.2.2
  • Develop the integration iteratively: first test connectivity with vanilla Rust, then add the Actix service, tests, handlers, and persistence. section 4.0

Querying a seeded course

Create ezy_course_c4 with course_id, tutor_id, course_name, and posted_time columns; insert two courses; set DATABASE_URL; then run a Rust program that queries course_id = 1 through PgPool. The program prints the First course record with its timestamp. section 4.2.2

Figure 1.2 Our example EzyTutors application

Use the application architecture diagram to locate Postgres alongside the Rust web service, server-rendered client, and persisted course data. section 1.3.1

How Rust Servers, Services, and Apps covers it

How deep it goes
Builds installation, credentials, schema, seed data, pooled connectivity, querying, and service integration, stopping short of advanced database operations.
Examples
Uses the ezytutors database, ezy_course_c4 table, seeded courses, psql commands, and a Rust PgPool query.
What it assumes
Assumes Rust project familiarity while teaching database installation, access credentials, table creation, environment configuration, and first connectivity checks.
What you can do after
Operate/configure PostgreSQL for a Rust service, create schemas and credentials, verify connectivity, and query persisted records through SQLx.
How it connects
Connects PostgreSQL with relational databases, SQLx, Rust, Actix Web, asynchronous I/O, connection pools, REST APIs, and database migrations.

Also explained in

Compare how 11 books explain PostgreSQL →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.