Srinivas 25
Srinivas 25

Reputation: 63

How to add Redis Database in Django-1.9?

I Want to add Redis Database in Django-1.9, so i followed this documents for integration https://niwinz.github.io/django-redis/latest/ But i didn't find any clue on how to mention Database name in the settings, Here i want to mention Redis as a database on behalf Sqlite3, If uncommented this line django is throwing an Error of DATABASE not found

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': os.path.join(BASE_DIR, 'sqlite3'),
}
}

Thanks in Advance for your solution

Upvotes: 3

Views: 6274

Answers (3)

Thrilok Kumar Pallaki
Thrilok Kumar Pallaki

Reputation: 142

CACHES = {
  "default": {
    "BACKEND": "django_redis.cache.RedisCache",
    "LOCATION": "redis://127.0.0.1:6379/0",
    "OPTIONS": {
      "CLIENT_CLASS": "django_redis.client.DefaultClient"
    }
}

}

To use the redis database in django you need to add this code to your settings file,based on your requirement you can change the value of the database at the end of LOCATION value like ("redis://127.0.0.1:6379/1") for database '1'. You can also check here: https://niwinz.github.io/django-redis/latest/#_configure_as_cache_backend

Upvotes: 2

Mira Nuata
Mira Nuata

Reputation: 470

By default Django provides no support for non-relational database backends. However, if you intend to use Redis as your primary database, you can take a look at Django non-rel.

Upvotes: 1

e4c5
e4c5

Reputation: 53734

What's django-redis?

django-redis is a BSD Licensed, full featured Redis cache/session backend for Django.

What's redis

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker

Essentially that means django-redis is a django package that allows you to replace the default memcache as django's cache backend and also allows you to replace the DB as the default session storage. However django-redis does not implement features required to use it as a replacement for sqlite3 or any other database.

Upvotes: 5

Related Questions