Skip to content
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

How can we specify the name of the test database? #102

Closed
Vadorequest opened this issue May 19, 2018 · 4 comments · Fixed by #116
Closed

How can we specify the name of the test database? #102

Vadorequest opened this issue May 19, 2018 · 4 comments · Fixed by #116
Labels
feature this is a request for a new feature

Comments

@Vadorequest
Copy link

Django supports a custom name for the test database, how can we specify this somehow?

See https://docs.djangoproject.com/en/1.8/ref/settings/#test

@Brodan
Copy link
Contributor

Brodan commented Jan 30, 2019

I'm also currently dealing with this issue. Any solutions?

@jacobian jacobian added the feature this is a request for a new feature label Jul 24, 2019
@mattseymour
Copy link
Contributor

mattseymour commented Jul 25, 2019

Currently, the database string allows for specifying the current fields.

  • Engine
  • User
  • Password
  • Host
  • Port
  • Name (database name)

All of these are set through the basic usage of the database string (for example: mysql://USER:PASSWORD@HOST:PORT/NAME

One proposal could be to use querystring arguments for additional database options.

For top level database options not already included in the database string (time_zone, conn_max_age, autocommit, atomic_requests). They could look something like:

mysql://USER:PASSWORD@HOST:PORT/NAME?CONN_MAX_AGE=120&AUTOCOMMIT=True

For database options or test which are a dictionary within the databases settings we could use a key prefix to represent the dictionary it is part of. This could be something like TEST__ to represent TEST options.

An example could be:

mysql://USER:PASSWORD@HOST:PORT/NAME?TEST__NAME=mytestdb

This proposal should also be able to help support other DB options such as SSL which i set under the OPTIONS. An example of such usage could be:

mysql://USER:PASSWORD@HOST:PORT/NAME?OPTIONS__NAME=mytestdb&OPTIONS__SSL__key=/opt/_certs/client-key.pem&OPTIONS__SSL__cert=/opt/_certs/client-cert.pem

Let me know your thoughts.

@jacobian
Copy link
Collaborator

@mattseymour my gut reaction is that this looks pretty inelegant; I don't love cramming stuff into the URL like this, and I find turning the flat URL into a dictionary... just too much. I think there's a certain point where, if you're doing complex stuff, you should just dive into the settings file.

My feeling is: the point of this library is to take a DATABASE_URL that's been handed to you by a provider (Heroku, Azure, etc) and use it with a minimum of fuss. That URL isn't going to have Django-specific stuff, so why support it?

I like the direction that #116 is taking, moving some of this stuff into the config() call. It's a bit cleaner than

DATABASES = dj_database_url.config()
DATABASE["default"]["TEST"]["name"] = "whatever"

But still doesn't require being all this URL stuff. Does that approach seem ok to you?

@mattseymour
Copy link
Contributor

Makes sense, I guess it depends on the use case of what people are willing to put into the database urls.
I was not sure if we wanted a purely url solution or if core information in the URL and additional
details in the configuration files.

In either case, I think it would be good to put in the read me the limitations and the thought process behind the scope of the library. Almost like what you put in your comment:

the point of this library is to take a DATABASE_URL that's been handed to you by a provider (Heroku, Azure, etc) and use it with a minimum of fuss. That URL isn't going to have Django-specific stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature this is a request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants