use a dsn for database details in settings.py ?

44 views
Skip to first unread message

Kumar McMillan

unread,
May 4, 2006, 7:39:44 PM5/4/06
to django...@googlegroups.com
Hi, I'm still new to django and have googled high and low for a way to
use a single dsn in the settings file instead of DATABASE_HOST,
DATABASE_USER, DATABASE_NAME, etc. No metion of it. Is there built
in support for this that I'm missing?

If not, I am happy to submit a patch. What is the best place in svn
to patch against? Magic removal branch or trunk?

If you're asking why, here is a common situation I have with database
configurations... In order to run in multiple environments I declare
DSNs as environment variables so that this detail is decoupled from
the code. This also lets multiple users set up dev environments
easily and keeps sensitive information out of the code repository. As
it works now, it would be cumbersome to deal with 6 separate env vars:
engine, name, user, password, host, port.

thanks, Kumar

Joseph Kocherhans

unread,
May 4, 2006, 7:47:13 PM5/4/06
to django...@googlegroups.com
On 5/4/06, Kumar McMillan <kumar.m...@gmail.com> wrote:
>
> Hi, I'm still new to django and have googled high and low for a way to
> use a single dsn in the settings file instead of DATABASE_HOST,
> DATABASE_USER, DATABASE_NAME, etc. No metion of it. Is there built
> in support for this that I'm missing?

You're not missing anything, it's not there :)

> If not, I am happy to submit a patch. What is the best place in svn
> to patch against? Magic removal branch or trunk?

The magic-removal branch was merged a few days ago, so it *is* the trunk now.

> If you're asking why, here is a common situation I have with database
> configurations... In order to run in multiple environments I declare
> DSNs as environment variables so that this detail is decoupled from
> the code. This also lets multiple users set up dev environments
> easily and keeps sensitive information out of the code repository. As
> it works now, it would be cumbersome to deal with 6 separate env vars:
> engine, name, user, password, host, port.

Sounds like a good idea to me. A patch would be great!

Joseph

pbx

unread,
May 4, 2006, 11:30:08 PM5/4/06
to Django users
> Hi, I'm still new to django and have googled high and low for a way to
> use a single dsn in the settings file instead of DATABASE_HOST,
> DATABASE_USER, DATABASE_NAME, etc. No metion of it. Is there built
> in support for this that I'm missing?
>
> If not, I am happy to submit a patch.

+1. I've wanted to do this for a while. Let me know if you want help
with the patch.

pb
--
http://e-scribe.com/news/

Kumar McMillan

unread,
May 8, 2006, 3:24:51 PM5/8/06
to django...@googlegroups.com
http://code.djangoproject.com/ticket/1810

have fun ;)


btw ... how are people running the test suite? Do you make a custom
test_settings.py module and keep it somewhere on your pythonpath?
That's what I was doing but it would be nice if there were default
settings that just started everything with sqlite3 if you didn't need
custom settings.

K

Reply all
Reply to author
Forward
0 new messages