On Thu, Sep 16, 2010 at 11:18 PM, keith <[email protected]> wrote: > I have an app that accesses two different databases which are defined > in settings.py > one of them is read-only and its models all have managed=False, when i > run 'manage.py test', unsurprisingly i guess, i get an insufficient > privileges error when trying to create/destroy > the testing database on the read-only database. > > is this a bug or and rfe?
RFE. Django doesn't currently have a concept of a "read only" database; when you run a test, it tries to create a test version of any database that is defined in DATABASES so that the test environment is isolated from production. It's an interesting idea though -- the concept of a truly 'external' data source that can be reliably used in testing isn't something that was considered as part of the multi-db design process. There have been requests in the past to be able to control whether the test setup is responsible for creating and destroying the test database. If we introduced such an option, it might be possible to use the TEST_NAME setting to point the test framework at your 'read-only' database. However, there are other details that would need to be finessed -- e.g., how does the test transaction rollback process work on a database that can't be written to? As a workaround for now, you should be able to write a custom database backend for your readonly database -- extend the Django builtin backend, but override the _create_test_db() and _destroy_test_db() functions on the creation module to be no-ops. Use this backend for your readonly database, and you will be able to use the TEST_NAME trick right now. Yours Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

