June 2017
Intermediate to advanced
446 pages
10h 10m
English
The chapter9_6.py file starts with the necessary imports. Note that the following request import is the request object from the client and not the requests package that we have been using in the previous chapters:
from flask import Flask, url_for, jsonify, requestfrom flask_sqlalchemy import SQLAlchemy# The following is deprecated but still used in some examples# from flask.ext.sqlalchemy import SQLAlchemy
We declared a database object with its ID as the primary key and string fields for hostname, loopback, management IP, role, vendor, and OS:
class Device(db.Model): __tablename__ = 'devices' id = db.Column(db.Integer, primary_key=True) hostname = db.Column(db.String(64), unique=True) loopback = db.Column(db.String(120), unique ...
Read now
Unlock full access