jazzband / dj-database-url

Use Database URLs in your Django Application.
https://pypi.org/project/dj-database-url/
BSD 3-Clause "New" or "Revised" License
1.48k stars 205 forks source link

multiple database support added #105

Closed hbasria closed 5 years ago

sjarvie commented 5 years ago

Would love to see this feature.

jacobian commented 5 years ago

Thanks so much for your work! However, I'm going to reject this for two reasons: (1) there's too much hidden behavior ("magic"), and (2) it's easy enough to do already in a more explicit way.

  1. Hidden behavior (aka "magic"): between looking env vars of the form {FOO}_DATABASE_URL and the lower-casing into settings.DATABASES, there's a bit too much magic here for my taste.

DATABASE_URL is enough of a de facto standard that automatically parsing it makes sense, but there's a lot difference in how providers specify multiple databases. Given those differences, this patch may not work broadly, and if/when it breaks it'll be confusing (databases will just silently vanish).

  1. It's possible to do this simply enough today, with code like this:
DATABASES = {
    "db1": dj_database_url.config("DB1_DATABASE_URL"),
    "db2": dj_database_url.config("DB2_MY_PROVIDER_NAMES_THINGS_WEIRD")
}

This avoids hidden behavior, makes it clear where config is coming from, and (bonus) doesn't increase the code surface.

I'd (happily!) accept a documentation patch with the above, but adding this feature isn't something I think is appropriate.

Thanks again for your work, sorry to have to reject it.