Reputation: 345
I am working on an flask project which contains a lot of models and some of them make use of from sqlalchemy.dialects.postgresql import JSONB
. From management, I created manage.py as per this link. python manage.py init & python manage.py migrate
are working fine but when I run python manage.py upgrade
the following error occurs in migrated file.
sa.Column('images', postgresql.JSONB(astext_type=Text()), nullable=True),
NameError: global name 'Text' is not defined
Does anyone know how to fix it?
Upvotes: 2
Views: 1963
Reputation: 23484
You need to import that Text
As i searched it comes from sqlalchemy.types
, so you need at the top of file import it
from sqlalchemy.types import Text
But you don't even need to supply astext_type
as a parameter, because it defaults to Text()
. From docs of sqlalchemy.dialects.postgresql.JSON
:
astext_type
the type to use for the
JSON.Comparator.astext
accessor on indexed attributes. Defaults totypes.Text
.
And sqlalchemy.dialects.postgresql.JSONB
is
Bases:
sqlalchemy.dialects.postgresql.json.JSON
Upvotes: 7