Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upenvironment variable `DATABASE_URL` not defined #1614
Comments
weiznich
added
the
question
label
Apr 5, 2018
This comment has been minimized.
|
This error message means that the environment variable |
sgrif
closed this
Apr 5, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
haruhinoshana commentedApr 5, 2018
hi good evening im new on using diesel i use it with rocket ... i do try to work diesel on rocket but i got
environment variable
DATABASE_URLnot defined errorheres my code
#![feature(plugin)]
#![plugin(rocket_codegen)]
#[macro_use]
extern crate rocket;
extern crate diesel;
extern crate dotenv;
use diesel::prelude::*;
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
use dotenv::dotenv;
use std::env;
// An alias to the type for a pool of Diesel SQLite connections.
type MysqlPool = Pool<ConnectionManager>;
// The URL to the database, set via the
DATABASE_URLenvironment variable.static DATABASE_URL: &'static str = env!("DATABASE_URL");
/// Initializes a database pool.
fn init_pool() -> Pool {
let manager = ConnectionManager::::new(DATABASE_URL);
Pool::new(manager).expect("db pool");
}
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
fn main() {
rocket::ignite()
.manager(init_pool())
.mount("/", routes![index])
.launch();
}
my rust version 1.27.0-nightly (637ac17c5 2018-04-03)