January 2019
Intermediate to advanced
520 pages
14h 32m
English
In our tool, we will implement two subcommands—add to add a new user, and list to retrieve all available users from the database. Import all the necessary dependencies and add the modules with schema and models:
extern crate clap;#[macro_use]extern crate diesel;extern crate failure;extern crate serde_derive;use clap::{ crate_authors, crate_description, crate_name, crate_version, App, AppSettings, Arg, SubCommand,};use diesel::prelude::*;use diesel::r2d2::ConnectionManager;use failure::Error;pub mod models;pub mod schema;
Since we are using the r2d2 crate, we also have to import ConnectionManager to use diesel's abstraction over the traditional database connection.
Read now
Unlock full access