views:

33

answers:

3

I'd like to respect the database as a "read-only" and never write to it. Is there a way to easily prevent syncdb from even bothering to check to update the database?

With Django 1.2 and the ability to have multiple databases, it'd like to be able to query a database for information. I'd never need to actually write to that database.

However, I'd be scared if syncdb ran and attempted to update that database (because I may not have a technically read-only account to that database). Mainly, I'd just like to use/abuse the Django ORM as a way to query that database.

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

A: 

but syncdb is for synchronisation of your models and the database... for me it is unclear what you are trying to achieve.

akonsu
A: 

If you don't need syncdb, don't run it, simple as that. Updating the database is what it does, so if you don't need that, you shouldn't run it - it doesn't do anything else.

However if you're actually asking how to prevent syncdb from running at all, one possibility would be to define a 'dummy' syncdb command inside one of your apps. Follow the custom management command instructions but just put pass inside the command's handle method. Django will always find your version of the command first, making it a no-op.

Daniel Roseman
+2  A: 

Heh, I guess I'll answer my own question (RTFM!)...

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

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

That's a definite start...

xyld