aboutsummaryrefslogtreecommitdiffstats
path: root/license-generator/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'license-generator/src/lib.rs')
-rw-r--r--license-generator/src/lib.rs26
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(())
}
}