Skip to Content
Flask Framework Cookbook - Second Edition
book

Flask Framework Cookbook - Second Edition

by Shalabh Aggarwal
July 2019
Beginner to intermediate
302 pages
9h 38m
English
Packt Publishing
Content preview from Flask Framework Cookbook - Second Edition

Getting ready

Flask-SQLAlchemy is the extension that provides the SQLAlchemy interface for Flask.

This extension can simply be installed by using pip as follows:

    $ pip3 install flask-sqlalchemy

The first thing to keep in mind with Flask-SQLAlchemy is the application configuration parameter that tells SQLAlchemy about the location of the database to be used:

app.config['SQLALCHEMY_DATABASE_URI'] = os.environ('DATABASE_URI') 

SQLALCHEMY_DATABASE_URI is a combination of the database protocol, any authentication needed, and also the name of the database. In the case of SQLite, this would look something like the following:

sqlite:////tmp/test.db 

In the case of PostgreSQL, it would look like the following:

postgresql://yourusername:yourpassword@localhost/yournewdb. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Writing a Web Application with Flask

Writing a Web Application with Flask

Doug Farrell
Mastering Flask

Mastering Flask

Jack Stouffer

Publisher Resources

ISBN: 9781789951295Supplemental Content