python - 在 python-django 中移动数据库

标签 python django sqlite postgresql

我是 python-django 初学者。

我开始用 PostgreSQL 做一个项目,但发现很难设置配置和依赖项。是否有可能我在 sqlite 中创建我的整个项目,然后转移到 PostgreSQL?

或者我必须从一开始就决定一个特定的数据库?

最佳答案

尽管它很容易设置,但如果您的选择最终落入 postgreSQL,我不建议开始使用 sqlite

Django ORM 试图“隐藏”differences数据库管理系统之间,但不可能对所有人都好:

Django attempts to support as many features as possible on all database backends. However, not all database backends are alike, and we’ve had to make design decisions on which features to support and which assumptions we can make safely.

sqlite 有很多限制、“特殊”处理和“角落”情况,请参阅:

请注意,如果您不听从建议 - 至少,请使用最新的 sqlite 版本,准备一堆测试并以高 test coverage 为目标- 这将有助于减少切换数据库后端步骤时的“头痛”。

希望对您有所帮助。

关于python - 在 python-django 中移动数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23838534/

相关文章:

python - Python列表和矩阵反转时的指针地址

python - 使用 Django-todo 时使用空数据库运行 makemigrations 时出现 "OperationalError: no such table: django_site"

django 关键字不能是表达式

jquery - 附加一个包含 jquery 的 django 模板

python 拉普拉斯过滤器返回错误的值

python - Windows 许可证 key 的所有排列

python - 音乐轨道数据库

java - 编写 SQL 查询以返回 2 个 sqlite 表中的所有字段(Android 应用程序)

python - 值错误 : operation parameter must be str

python - 在 Python 中删除前导/结尾和内部多个空格但不删除制表符、换行符或返回字符