[英]How to find out what database (e.g. wether using mysql/pgsql/?) in a django south migration?
I'm writing a migration using Django's South, and it can only work on MySQL databases.我正在使用 Django 的 South 编写迁移,它只能在 MySQL 数据库上运行。 Is there anyway I can find out what database is being used (ie is this running on mysql or is it on postgres, etc.).无论如何我可以找出正在使用的数据库(即这是在 mysql 上运行还是在 postgres 上运行等)。 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.我正在编写一个重要的迁移(重命名伪造密钥),我认为它只适用于 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 that'll almost certainly only run on mysql, however I want to be doubly sure in case.这是针对内部 django 站点的,该站点几乎可以肯定只在 mysql 上运行,但我希望以防万一。
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.我不认为南说迁移是用哪个数据库创建的,而不是看南,你可以看看 django 设置,看看他们配置了什么数据库。
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.查看他们在设置中设置的数据库引擎,如果它是其他东西,那么“django.db.backends.mysql”会抛出你的异常。
https://docs.djangoproject.com/en/1.3/ref/settings/#engine https://docs.djangoproject.com/en/1.3/ref/settings/#engine
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.