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

Add support for extra settings like ATOMIC_REQUESTS #117

Closed pakal closed 5 years ago

pakal commented 5 years ago

The need is similar to https://github.com/kennethreitz/dj-database-url/issues/106, these kinds of settings are not in OPTIONS dict so they can't be passed in the query string of the DB url.

Maybe a special syntax is needed, for some query string parameters to be directly including as top-level fields of the final config ?

jacobian commented 5 years ago

I don't love the idea of some special syntax, especially given that it's fairly easy to just modify the DATABASES dict after it's read from the environ.

I could be convinced to change my mind if there was some especially elegant way of doing this, but I'd need to see an example. I'm going to close this, but if you come up with a good proposal please feel free to re-open.

dcwatson commented 3 years ago

Sorry to necro this, I can open a fresh issue if you'd prefer.

I think there's a good argument for allowing you to pass atomic_requests or autocommit to parse/config as kwargs -- these (in addition to conn_max_age which you can already pass) are always set on Django's connections:

https://github.com/django/django/blob/021f946569d0714fccd090bb2a5f1d7ab2720447/django/db/utils.py#L159

I could also see future-proofing this and just allowing for any kwargs to be automatically uppercased and included, but the existing ssl_require is somewhat of a special case then. Either way, I think it's a simple change and would be happy to open a PR for it.