flask_restplus_sqlalchemy package

Submodules

flask_restplus_sqlalchemy.factory module

Api Model Factory Contains instace of factory for use by swagger

class flask_restplus_sqlalchemy.factory.ApiModelFactory(api: flask_restplus.api.Api, db: flask_sqlalchemy.SQLAlchemy, logger=<Logger flask_restplus_sqlalchemy.factory (WARNING)>)

Bases: object

Api Model Factory takes in Flask Rest API and SqlAlchemy models then generates Flask Rest API Models needed for use with swagger and marshal

Parameters:
  • api (Api) – flask_restplus Api instance to which is needed for api.model function call
  • db (SQLAlchemy) – instance with the models load, failure to do correct initialization order will result in error
  • logger (Logger) – logging instance will use get_logger(__name__)

Note

Any model that you wish to display must not have __abstract__=True as this will make it hidden.

static auto_generate_meta_form(model) → dict

Generates the dict meta form needed by api.model

Parameters:model (any) – the flask model
Returns:Intermidate form needed for api.model
Return type:dict
entities = {}

Dict with __tablename__, Model

get_entity(table_name: str) → flask_restplus.model.Model

Helper function to get entity by name from dict of entities

Parameters:table_name (str) – the table name will match what you have in __tablename__ for a given model.
Returns:Table Api Model from list
Return type:flask_restplus.model.Model
Raises:Exception – Table Name was not found, Check that you have not called this function be for initlizing the db: SQLAlchemy object with the models
static get_python_type(column) → type

Get the python type

logger = None

Logger, you can disable by sending out put to null or None

static python_to_flask(python_type: type) → str

Converts python types to flask types

Parameters:python_type (type) – type that is to be converted into flask type
Returns:flask type represented as a string
Return type:str
schema = {}

Intermediate form of Use By api.model

Module contents

Factory for use with Flask SQL