'SQLAlchemy Utils URLType not defined when flask db upgraded

I've used import sqlalchemy_utils in both env.py and script.mayo.py and even described this method.

def render_item(type_, obj, autogen_context):
    if type_ == "type" and isinstance(obj, sqlalchemy_utils.types.URLType):
        autogen_context.imports.add("import sqlalchemy_utils")

        autogen_context.imports.add("import URLType")

        return "sqlalchemy_utils.types.URLType"

    return False

Still on flask db upgrade command following error comes up.

in upgrade
    sa.Column('question_link', sqlalchemy_utils.types.url.URLType(), nullable=True),
NameError: name 'sqlalchemy_utils' is not defined


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source