New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose multi-db connection inference from diesel-cli #1853

Closed
igalic opened this Issue Sep 17, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@igalic

igalic commented Sep 17, 2018

Setup

in Plume and Rustodon we want to support PostgreSQL and SQLite for smaller or dev/test setups.
Both projects are currently working on patches adding SQLite support: Plume-org/Plume#226 rustodon/rustodon#12

Versions

  • Rust: nightly
  • Diesel: 1.3.×
  • Database: postgres & sqlite
  • Operating System

Feature Flags

[dependencies.diesel_cli]
features = ["postgres", "sqlite"]
version = "1.3.1"

[dependencies.diesel]
features = ["postgres", "sqlite", "r2d2", "chrono"]
version = "*"

Problem Description

our problem is that we have to reimplement a lot of diesel-cli functionality for the setup and the normal operation of the program if you want to support more than one database.

currently, this seems to be in

pub enum InferConnection {
#[cfg(feature = "postgres")]
Pg(PgConnection),
#[cfg(feature = "sqlite")]
Sqlite(SqliteConnection),
#[cfg(feature = "mysql")]
Mysql(MysqlConnection),
}
impl InferConnection {
pub fn establish(database_url: &str) -> DatabaseResult<Self> {
match Backend::for_url(database_url) {

but i'm not sure how to acces or if that's possible at all

What are you trying to accomplish?

We would like to easily use both databases transparently

Checklist

  • I have already looked over the issue tracker for similar issues.

this might be related to #357

  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)

@igalic igalic referenced this issue Sep 17, 2018

Open

Add SQLite backend #12

7 of 9 tasks complete
@sgrif

This comment has been minimized.

Member

sgrif commented Sep 17, 2018

Thanks for the feature request. I can see why pulling this out of Diesel CLI might be useful for your use case. However, there's a big difference from both a design and maintenance point of view between something hacked together for internal use, vs something we're comfortable supporting as a stable API designed for public consumption.

Hopefully it's clear why providing a public API for this is a lot more work than "just making this code public".

While multi-db support is possible with Diesel, it's not a primary goal of the project. For that reason, developing a feature like this simply isn't on the roadmap in the near future. That said, if the code in Diesel CLI today suits your need, and you feel it's acceptable to maintain as a public API, I'd encourage you to take it and release it as your own crate. Diesel might even end up depending on it.

However, I don't see this feature getting implemented as a standalone library any time soon.

@sgrif sgrif closed this Sep 17, 2018

@igalic

This comment has been minimized.

igalic commented Sep 18, 2018

Thank you very much for this reply — it does help put things into perspective.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment