standardizing no-ORM database settings

hi

so i’m working on a package called django-valkey.
it’s currently a cache only package, but i wanted to add persistent database support.

but i don’t see any conventions on how a database related package should be set up.

for example, should i re-use django’s DATABASES variable? or introduce a new variable?
or the object that is used to work with database, what should i name that?
one option is db, so we can do db.get() and…

but i’m looking for a standard so other packages could follow, i’d be happy to hear your thoughts on how we can make a standard here.

I’m not quite sure what you’re looking to accomplish, can you help clarify some things for me please? Are you looking to use the ORM with valkey? Or are you looking for a Django-specific wrapper around Valkey for other features that aren’t exposed through caching?

hi
no i don’t intend to make an ORM.

and the question is not valkey specific, i just implement it for valkey, but i want something general for other packages as well.

what i’m looking for is making a convention on how databases that don’t have an ORM (no-sql), should be set up in a django project

for example, normally you put your database connection information in DATABASES, but should that be a ORM specific setting? or we should reuse it for no-sql as well?

or what should be the object name that connects to database?
e.g. we have django.core.cache.caches that contains all the servers and django.core.cache.cache that connects to the main server and youcan do cache.get().

a similar object is required to connect to no-sql databases. but what should be it’s name?
or is there a better way?

1 Like

If it’s a database, you’ll want to use DATABASES, so you can use the ORM. If it’s just a key-value store, CACHES probably makes sense. If you want to add some additional functionality, you can always add extra methods to your cache wrapper.

As for no-SQL, there’s a backend for Mongo which lets you use it as an ORM, which might be of interest to you.

1 Like

Hi
i’m not making an ORM

it is said that django ORM doesn’t support no-sql(at least not built-in), but is there anything stopping us from using a normal client to connect to server like cassandra or anything else?
as far as i know we can simply do:

from cassandra.cluster import Cluster

cluster = Cluster()

what i’m looking for is to make some sort of convention on how these connections should be set up, and if a library wants to support this, how they should do it.

The apparent lack of support in Django is because of the ORM. It’s really designed for a relational database, rather than a document-based one (although it’s still possible).

“A database” isn’t really a thing otherwise. There isn’t really a convention for “things which have persistent connections but aren’t DATABASES or CACHES compatible”, because it’s hard to define what that API would even look like.