oTree Forum >

Finally switched to Django-less oTree. Just want to double-check on database access

#1 by ExperimenterDan

With Heroku no longer supporting versions of Python that work with 'old' Django-integrated oTree, I'm finally switching. Overdue, I know! 

Anyway, one thing I actually liked about Django was being able to use Django filters for database functions (SELECT equivalent, INSERT, UPDATE, etc.). With oTree, I never had to do much of this of course, but we do at times have the need for "direct" use of the database here and there. For example, in a decoding task, I used a table to store decoding info, and pulled that out using filters on that model. Or, in a multi-stage experiment, I used it do a pseudo-match of participants so that nobody got stuck waiting. 

I read through all the docs again and searched this forum, but just wanted to double-check that there is no equivalent in the Django-less oTree. In other words, is establishing a direct database connection and executing raw SQL the only alternative for this type of thing now? Thanks!

#2 by gr0ssmann

Have you considered using an ExtraModel? https://otree.readthedocs.io/en/latest/misc/advanced.html#extramodel

#3 by ExperimenterDan

Thank you very much! I hadn't looked closely enough at that the first time back through the docs. That can definitely work for some instances. For others (again not many times we need to in the first place), I think I'll just plan on executing some raw SQL via Python.

Write a reply

Set forum username