# Database for Development Enviroment

**URL:** <https://forum.djangoproject.com/t/database-for-development-enviroment/11422>\
**Category:** Using Django\
**Created:** [January 7, 2022, 4:03am UTC](https://forum.djangoproject.com/t/database-for-development-enviroment/11422 "2022-01-07T04:03:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![colina83](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/colina83/32/6569_2.png) [@colina83](https://forum.djangoproject.com/u/colina83)\
**Post date:** [January 7, 2022, 4:03am UTC](https://forum.djangoproject.com/t/database-for-development-enviroment/11422/1 "2022-01-07T04:03:18Z")

</div>

Hi All,

I made the perhaps mortal mistake of using Sqlite3 for development, as opposed to starting with Postgres from the get go, obviously, I deployed the application with Postgres using Heroku, and well now I’m stuck with this problem:

Essentially, I have to switch back from Databases, one for the development server, and then change the settings.py to reflect the development.

```auto
# This is the DATABASE for production
DATABASES = {
    'default': dj_database_url.config(
        default=env('DATABASE_URL')
    )
}

"""
# This is the old sqlite3 use for development enviroment
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}
"""

```

I’m using windows, and I have set the environmental variable as followed:

```auto
set DATABASE_URL="sqlite://../db.sqlite3"

```

The step above is not working, obviously, I don’t want to be commenting out the settings.py - Does anyone know what can I do to fix this issue?

if I leave the development DB, I’m getting this error:

```auto
django.core.exceptions.ImproperlyConfigured: Set the DATABASE_URL environment variable

```

Regards  
FCS

---

<div class="post-metadata">

**Author:** ![MSoup](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/msoup/32/6957_2.png) [@MSoup](https://forum.djangoproject.com/u/MSoup)\
**Post date:** [January 7, 2022, 5:33am UTC](https://forum.djangoproject.com/t/database-for-development-enviroment/11422/2 "2022-01-07T05:33:50Z")

</div>

Forgive me if I lead you astray, but I also was faced with the task of switching between databases, and came up with a bandaid solution:

> [@\[settings.py\] How do I change the DB used when project is spun up in ci/cd (github actions)?](https://forum.djangoproject.com/t/settings-py-how-do-i-change-the-db-used-when-project-is-spun-up-in-ci-cd-github-actions/11420):
>
> My apologies if this has been answered already. I am trying to figure out how to get Django to use sqlite3 when doing automated tests through github actions, but use mssql when run locally. The reason is because well… I can’t just spin up a mssql server instance in my github actions, or not that I am aware of. Perhaps there is a better solution that gets around this problem to begin with, and I’m all ears. So far, I’ve tried something like this: settings.py if len(sys.argv) \> 2 and sys.argv[2…

If this isn’t what you’re looking for, I apologize!

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 7, 2022, 1:00pm UTC](https://forum.djangoproject.com/t/database-for-development-enviroment/11422/3 "2022-01-07T13:00:51Z")

</div>

See docs at [GitHub - kennethreitz/dj-database-url: Use Database URLs in your Django Application.](https://github.com/kennethreitz/dj-database-url) for the format of the `DATABASE_URL` used for sqlite. Notice there are 3 slashes after `sqlite:`

---

<div class="post-metadata">

**Author:** ![typonaut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/typonaut/32/2316_2.png) [@typonaut](https://forum.djangoproject.com/u/typonaut)\
**Post date:** [January 7, 2022, 11:01pm UTC](https://forum.djangoproject.com/t/database-for-development-enviroment/11422/4 "2022-01-07T23:01:16Z")

</div>

What I tend to do with settings sf have a development settings file and a deployment settings file, but when the dev stuff gets moved to deployment the settings file isn’t copied. if you’re doing it with git, then put it in the `gitignore`.

The obvious problem is that if you update the dev with something that needs to be in the deployment settings, then you are going to need to keep track of that… But you don’t have to keep editing the settings file between the two (or more) environments.

---

<div class="post-metadata">

**Author:** ![speno](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/speno/32/179_2.png) [@speno](https://forum.djangoproject.com/u/speno)\
**Post date:** [January 8, 2022, 12:36pm UTC](https://forum.djangoproject.com/t/database-for-development-enviroment/11422/5 "2022-01-08T12:36:49Z")

</div>

Also, if you aren’t using PostgreSQL as your test database, you should be careful not to use any PostgreSQL specific features in your code. One thing that I encountered was using the `*fields` argument to `.distinct()` which only works in PostgreSQL, not in Sqlite which I was using for tests. For that reason, I now use the same DB for prod, dev, and test.
