I'm writing a migration using Django's South, and it can only work on MySQL databases. Is there anyway I can find out what database is being used (i.e. is this running on mysql or is it on postgres, etc.). I want to then raise an exception.
I am writing a nontrivial migration (renaming forgein keys), and I think it'll only work on MySQL. In keeping with the south/python ideology of not proceeding if you can't guarantee it'll work, I want to raise an exception if I'm unsure it'll complete successfully.
This is for an internal django site t开发者_开发问答hat'll almost certainly only run on mysql, however I want to be doubly sure in case.
I don't think south says which database the migration was created with, instead of looking at south could you look at the django settings and see what database they have configured.
Look at the database engines they have set in the settings and if it is something other then "django.db.backends.mysql" throw your exception.
https://docs.djangoproject.com/en/1.3/ref/settings/#engine
精彩评论