diff options
author | Teddy Wing | 2018-11-09 14:50:29 +0100 |
---|---|---|
committer | Teddy Wing | 2018-11-09 14:50:29 +0100 |
commit | 0a11429d59d0955ad19d798506b410cb7453b76e (patch) | |
tree | 3dd33efed98a58836a4054a7106c20e35bbff36b | |
parent | ff4a601cf4dd678ae0d1f939de313a5eba012905 (diff) | |
download | dome-key-web-0a11429d59d0955ad19d798506b410cb7453b76e.tar.bz2 |
Purchaser: Implement `insert()`
Haven't tested this at all so I have no idea if it works. Just getting a
draft committed.
-rw-r--r-- | license-generator/src/lib.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/license-generator/src/lib.rs b/license-generator/src/lib.rs index 6bc49ee..9f73f6b 100644 --- a/license-generator/src/lib.rs +++ b/license-generator/src/lib.rs @@ -3,7 +3,13 @@ extern crate error_chain; extern crate mysql; mod errors { - error_chain! {} + use mysql; + + error_chain! { + foreign_links { + MySql(mysql::error::Error); + } + } } use errors::*; @@ -28,7 +34,21 @@ impl<'a> Purchaser<'a> { self } - fn insert() -> Result<()> { - unimplemented!() + fn insert(&self, cx: &mut mysql::Conn) -> Result<()> { + let mut tx = cx.start_transaction( + false, // consistent_snapshot + None, // isolation_level + None, // readonly + )?; + + tx.prep_exec(" + INSERT INTO purchasers + (name, email, secret) + VALUES + (?, ?, ?)", + (self.name, self.email, self.secret), + )?; + + Ok(()) } } |