Friday, October 4, 2013

Re: Disabling object persistence ?

On Fri, Oct 4, 2013 at 1:45 AM, Marc'h <mhoebeke@gmail.com> wrote:
> Thus, I'd like to know if there is any means to by-pass the automatic
> persistence mechanism when using collection attributes which are foreign-key
> based.


the ORM is a mapping to an SQL database, by definition that means
persistent storage. while you can create a model object and not
save() it, relationships are based on the record's primary key, which
is assigned (by the RDBMS) only when save()d.

so, no; there's no "direct" way to avoid persistence and use
relationships. in fact, any kind of query works only via the
database.

memory-only SQL tables would do the trick, but most implementations
use them only for connection-private tables. after a cursory re-read
of SQLite docs, I don't see any way to create a shared memory table,
the "file::memory:?cache=shared" URI only means that it is shared
between different connections on the same process

a not-so-nice option could be to specify a RAM disk (or tmpfs)
location for your database. it would sitll be file-based, and
persistant over different invocations, but faster and less durable
than a real disk file.

if not, then i think you should avoid the ORM and use a shared memory
storage; either memcached, Redis, uWSGI cache, or something similar.
it's not relational, but you should be able to create the needed
queries without too much trouble.

--
Javier

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFkDaoRAnqrqbPNN7YH3eejdaKAVxRk_HE1EA5FQfp-FpfrW3A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate