Re: Feature request: Possibility to declare transactions as read only

2020-07-01 Thread Adam Johnson
Christian, FYI you can do this already for all new connections with something like this in an apps.py: from django.db.backends.signals import connection_created @connection_created.connect def transactions_readonly(*, connection, **kwargs): with connection.cursor() as cursor: cursor.e

Re: Feature request: Possibility to declare transactions as read only

2020-07-01 Thread Szeles Andor
Hello Simon and Christian, good point, making a particular connection read only would be even better than using a modified atomic. This way, if I really do need to use a read only transaction, I could just simply wrap my view inside an atomic decorator like @transaction.atomic(using='readonly')

Re: Feature request: Possibility to declare transactions as read only

2020-07-01 Thread Christian González
Am 01.07.20 um 20:28 schrieb charettes: Do you think that allowing a readonly boolean flag[0] to be specified in OPTIONS per connection like we do for isolation level[1] could work for your use case? From my experience this particular problem is usually dealt with by using database routers

Re: Feature request: Possibility to declare transactions as read only

2020-07-01 Thread charettes
Hello Andor, I think it would make sense to add this feature to Django but I'm not convinced per-atomic block granularity is the best API to expose this rarely used pattern. For example, how should this option behave when nesting atomic block and mixing readonly values or disabling usage of sa

Feature request: Possibility to declare transactions as read only

2020-07-01 Thread Andor
Greetings Django developers, I'd like to explicitly declare some of my database transactions as read only to enable certain optimizations, but after inspecting the documentation, forums and source code, it seems this feature is missing. As far as I understand, https://docs.djangoproject.com/en