Skip to Content
Python Microservices Development
book

Python Microservices Development

by Tarek Ziadé
July 2017
Beginner to intermediate
340 pages
7h 43m
English
Packt Publishing
Content preview from Python Microservices Development

Model

In a Flask application based on SQLAlchemy, the model is described through classes, which represent the database schema.

For Runnerly, the database tables are:

  • User: This contains info about each user, including their credentials
  • Run: This is a list of runs with all the info extracted from Strava, and runs for a training plan
  • Race: This is a list of races added by users, with date, location, and distance
  • Plan: This is a training plan that is defined by a collection of runs to be done

Using the Flask-SQLAlchemy (http://flask-sqlalchemy.pocoo.org/) extension, you can specify the tables using the Model class as a base class. The following is the definition for the User table with the SQLAlchemy class:

 from flask_sqlalchemy import SQLAlchemy ...
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

Python Microservices Development - Second Edition

Python Microservices Development - Second Edition

Simon Fraser, Tarek Ziadé
Python Web Development with Sanic

Python Web Development with Sanic

Stephen Sadowski, Adam Hopkins

Publisher Resources

ISBN: 9781785881114Supplemental Content