myloginrs
Read and parse MySQL's .mylogin.cnf file.
Installation
Add myloginrs
to Cargo.toml
:
[]
= "0.1"
Examples
To get a HashMap of login info for "client"
just use the parse function:
let file_path = from;
let client_info = parse;
Then you can use that HashMap with an OptsBuilder
or other structs
from the mysql:
let opts = new
.ip_or_hostname
.tcp_port
.user
.pass;
let _conn = new;
Starting with mysql 20.1.0, you can do the even simpler:
let opts = new.from_hash_map.unwrap;
let _conn = new;
If you would rather get a String that contains the whole file, use read:
let mylogin_plaintext = read;
println!;
This second example passes None
as the path to use the
default .mylogin.cnf location (%APPDATA%\MySQL\.mylogin.cnf
on windows or
~/.mylogin.cnf
on everything else).
Other Stuff
Thanks to
- github.com/PyMySQL and
- github.com/ocelot-inc for doing all the hard work and from whom I port.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Pull requests welcome. :)
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.