简体   繁体   English

如何找出 django 南迁移中的数据库(例如是否使用 mysql/pgsql/?)?

[英]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.

相关问题 使用South(django)和MySQL进行模式迁移 - Schema migration with south (django) and MySQL Django South不应用数据库迁移 - Django south not applying database migration Django South迁移不更新数据库 - django south migration not updating database 如何使用计算方法(例如使用Python)找到以下所需概率? - How to find the following desired probability using computational method (e.g. using Python)? 使用NLTK查找事物列表(例如河流列表) - Find a list of things (e.g. a list of rivers) using NLTK 如何使用 nltk 找出英语中是否存在某个单词 - How to find out wether a word exists in english using nltk Django 迁移错误:错误:“选择”必须是可迭代的(例如,列表或元组) - Django Migration Error: ERRORS: 'choices' must be an iterable (e.g., a list or tuple) Django数据迁移,使用South with Inheritance - Django Data Migration, using South with Inheritance 使用Django South进行外键迁移 - Foreign key migration using django south 多个嵌套函数需要在 python 中处理连接(例如,使用 MySQLdb 连接到 mysql 服务器)的最佳方法是什么? - What is the best way to handle connections (e.g. to mysql server using MySQLdb) in python, needed by multiple nested functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM