简体   繁体   中英

Web App Database Setup

Firstly, I have searched Yahoo and haven't found a good answer.

All the Flask SQLAlchemy tutorials use SQLite, but from what I read SQLite isn't really good with Heroku - or at least a Yahoo search of SQLite Heroku - reveals many issues with it?

If there aren't in fact any issues with using SQLite, please let me know.

How do I set a database up with Postgres and FlaskSQLAlchemy - since from my research that is what Heroku supports?

Using Flask-SQLAlchemy, you can just do this:

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://username:password@host/dbname'
db = SQLAlchemy(app)

Now you can use this db object to do whatever you need.

Read here for more: http://packages.python.org/Flask-SQLAlchemy/config.html#configuration-keys

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM