aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index cb4e384..6605693 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,6 +11,10 @@ extern crate time;
extern crate diesel_migrations;
#[cfg(feature = "mysql")]
extern crate diesel;
+#[cfg(feature = "mysql")]
+extern crate r2d2;
+#[cfg(feature = "mysql")]
+extern crate r2d2_diesel;
#[macro_use]
extern crate log;
@@ -119,13 +123,16 @@ fn main() {
#[cfg(feature = "mysql")]
{
if let Some(url) = mysql_url {
- use diesel;
- use diesel::Connection;
- match diesel::mysql::MysqlConnection::establish(url) {
- Ok(conn) => {
- match embedded_migrations::run(&conn) {
+ use diesel::MysqlConnection;
+ use r2d2;
+ use r2d2_diesel::ConnectionManager;
+
+ let manager = ConnectionManager::<MysqlConnection>::new(url.clone());
+ match r2d2::Pool::builder().build(manager) {
+ Ok(pool) => {
+ match embedded_migrations::run(&*pool.get().expect("Failed to get connection")) {
Ok(_) => {
- bot.add_plugin(plugins::Factoids::new(conn));
+ bot.add_plugin(plugins::Factoids::new(pool));
info!("Connected to MySQL server")
}
Err(e) => {