I'd highly recommend using the same database backend in production as in development, and all stages in between. Django will abstract the database stuff, but having different environments will leave you open to horrible internationalisation, configuration issues, and nasty tiny inconsistencies that won't even show up until you push it live.
Personally, I'd stick to mysql, but I never got on with postgres :)
I second all previous answers, adding some explicit reasons:
MySQL issues Warning exception when you try to store string longer that field width - you won't get them in SQLite, so not only you're string will be different between dev and production, but also program behaviour
bugs in both backends are different - I remember that once I tried SQLite for dev and MySQL for production, but it turned out that I discovered a bug in MySQL backend which was not present in SQLite one. So I filed a ticket for it and switched to MySQL for testing :-)
And you can even try to compete with SQLite in terms of speed, take a look at my answer for other question:
As much as the ORM tries to abstract the differences between databases, there will always be certain features that behave differently based on the database. Database portability is a complete myth.
Plus, it seems pretty insane to test and develop against code paths that you will never use in production, doesn't it?
刚刚从 sqlite 开始犯了这个重大错误,当我尝试使用 mysql 在生产服务器上部署时,事情并没有像我预期的那样顺利。我尝试使用各种开关转储数据/加载数据,但不知怎的,不断出现一个又一个的错误。帮自己一个大忙,使用相同的数据库进行生产和开发。
Just made this major mistake starting off with sqlite and when i try to deploy on production server with mysql, things didn't work as smooth as i expected. I tried dumpdata/loaddata with various switches but somehow keep getting errors thrown one after another. Do yourself a big favor and use the same db for both production and development.
发布评论
评论(6)
我强烈建议在生产中和开发中以及其间的所有阶段使用相同的数据库后端。 Django 会抽象数据库的内容,但是不同的环境会让你面临可怕的国际化、配置问题和令人讨厌的微小不一致,这些不一致甚至在你将其推送到上线之前都不会出现。
就我个人而言,我会坚持使用 mysql,但我从来没有使用过 postgres :)
I'd highly recommend using the same database backend in production as in development, and all stages in between. Django will abstract the database stuff, but having different environments will leave you open to horrible internationalisation, configuration issues, and nasty tiny inconsistencies that won't even show up until you push it live.
Personally, I'd stick to mysql, but I never got on with postgres :)
我支持以前的所有答案,添加一些明确的原因:
你甚至可以尝试在速度方面与 SQLite 竞争,看看我对其他问题的回答:
提高 Django 中 MySQL 表创建的速度?
I second all previous answers, adding some explicit reasons:
And you can even try to compete with SQLite in terms of speed, take a look at my answer for other question:
Increase speed for MySQL table creation in Django?
你为什么要这么做?
Why would you want to do that?
在所有环境中使用相同的数据库。
尽管 ORM 试图抽象数据库之间的差异,但总会有某些功能根据数据库的不同而表现不同。数据库可移植性完全是一个神话。
另外,针对您在生产中永远不会使用的代码路径进行测试和开发似乎非常疯狂,不是吗?
Use the same database in all environments.
As much as the ORM tries to abstract the differences between databases, there will always be certain features that behave differently based on the database. Database portability is a complete myth.
Plus, it seems pretty insane to test and develop against code paths that you will never use in production, doesn't it?
简而言之,不;除非你想不必要地加倍开发时间。
In short, no; unless you want to unnecessarily double development time.
刚刚从 sqlite 开始犯了这个重大错误,当我尝试使用 mysql 在生产服务器上部署时,事情并没有像我预期的那样顺利。我尝试使用各种开关转储数据/加载数据,但不知怎的,不断出现一个又一个的错误。帮自己一个大忙,使用相同的数据库进行生产和开发。
Just made this major mistake starting off with sqlite and when i try to deploy on production server with mysql, things didn't work as smooth as i expected. I tried dumpdata/loaddata with various switches but somehow keep getting errors thrown one after another. Do yourself a big favor and use the same db for both production and development.