O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

PostgreSQL

While SQLite is fine for the smaller problems, a real relational database can make the life of a business application coder much easier. The most popular PostgreSQL library is simply named postgres. It's a native Rust client, meaning that it does not ride on a C library but implements the whole protocol in Rust. If the API looks familiar, it is deliberate; the SQLite client's API is actually based on that of the PostgreSQL client.

The driver supports some of PostgreSQL's interesting features, such as bit vectors, time fields, JSON support, and UUIDs. Our example will use the time fields, a UUID for a primary key, and the JSON type for generic data.

We'll start by doing the shortest possible PostgreSQL initialization. How this works ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required