是否可以使用Sqlite部署Django? [英] Is it possible to deploy Django with Sqlite?

查看:82
本文介绍了是否可以使用Sqlite部署Django?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个使用sqlite(默认数据库)的Django应用,但找不到任何可以使用sqlite进行部署的地方。 Heroku仅适用于postgresql,而且我花了两天的时间来尝试切换数据库,但无法解决,所以我只想使用sqlite进行部署。 (这只是一个小应用程序。)

I've built a Django app that uses sqlite (the default database), but I can't find anywhere that allows deployment with sqlite. Heroku only works with postgresql, and I've spent two days trying to switch databases and can't figure it out, so I want to just deploy with sqlite. (This is just a small application.)

一些问题:


  • 我可以使用sqlite进行部署吗?

  • 如果可以,在哪里/如何?

推荐答案

SQLite是磁盘上的数据库,对于开发目的非常有用,但是诸如Heroku之类的服务希望您的服务器端代码是无状态的,因此实际上并不允许使用数据库例如SQLite。我想您可以使它工作(只要您在Heroku的磁盘上找到放置SQLite数据库的位置),但是每次重新部署时,都会不断丢失数据库的内容。

SQLite is a database on the disk, it is very useful for development purposes, however services like Heroku expect your server-side code to be stateless, which as a consequence does not really allow for databases such as SQLite. I guess you could make it work (provided you find a place on Heroku's disk where to put your SQLite db) but you would constantly lose your database's content every time you redeploy.

对于Heroku,我将您重定向到此链接,其中说明了如何在Heroku上将Django与PostgreSQL结合使用。

For Heroku specifically, I'll redirect you to this link which explains how to use Django with PostgreSQL on Heroku.

这篇关于是否可以使用Sqlite部署Django?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆