Prevent database update synchronization in Django?

I would like to respect the database as read-only and never write to it. Is there a way to easily prevent synchronization even from having to check for database updates?

With Django 1.2 and the ability to have multiple databases, he would like to be able to query the database for information. I never had to write to this database.

However, I would be scared if syncdb ran and tried to update this database (because I might not have a technically readable account for this database). Basically, I just would like to use / abuse Django ORM as a way to query this database.

UPDATE: Sorry, I need to be able to synchronize one of the databases in settings.py, and not just this particular one.

+3
source share
3 answers

Heh, I think I will answer my question (RTFM!) ...

http://docs.djangoproject.com/en/dev/topics/db/multi-db/#an-example

def allow_syncdb(self, db, model):
     ...

This is a definite start ...

+4
source

If you do not need syncdb, do not run it, just like that. Updating the database is what it does, so if you do not need it, you should not run it - do nothing.

, , syncdb, 'dummy' syncdb . , pass handle. Django , -op.

+1

Microsof SQL Server (uhhg). syncdb . syncdb, Django , (, south). , , Django, . , syncdb , db , south !

manage.py schemamigration ap_with_read_only_database --empty initial_empty_migration_that_does_nothing

db django.

0

Source: https://habr.com/ru/post/1759600/


All Articles