January 2019
Intermediate to advanced
520 pages
14h 32m
English
We will reuse the arguments parser from the previous example, but will rewrite the code that establish a connection, because we're using MySQL instead of PostgreSQL now. First, we replaced the database link with the mysql scheme. We will use the same parameters for the connection as those that we used to bootstrap the MySQL server instance.
We convert the address string to the Opts - options of a connections, the type of mysql crate that's used to set parameters for connections. But MysqlConnectionManager expects us to provide an OptsBuilder object. Look at the following code:
let addr = matches.value_of("database") .unwrap_or("mysql://root:password@localhost:3306/test");let opts = Opts::from_url(addr)?;let builder ...Read now
Unlock full access