Skip to content

Mongoengine Connection Failure: You have not defined a default connection #2582

@BrayanMota

Description

@BrayanMota

Start a python project, using fastapi with mongoengine. Yesterday it was working normally, but today when running any method that has the connection to the database, the connection failure error occurs (mongoengine.connection.ConnectionFailure: You have not defined a default connection ).

My connection:

from mongoengine import connect

connect(db="mydb", host='localhost', port=27017, alias='default')

My models:

from mongoengine.document import Document
from mongoengine.fields import StringField, BooleanField, ListField, ReferenceField
from mongoengine import PULL


class Permissao(Document):
    permissao = StringField()


class Grupo(Document):
    grupo = StringField()
    
    permissoes = ListField(ReferenceField('Permissao', reverse_delete_rule=PULL))


class Usuario(Document):
    nome_usuario = StringField()
    ativo = BooleanField()
    senha = StringField()
    
    grupos = ListField(ReferenceField('Grupo', reverse_delete_rule=PULL))
    permissoes = ListField(ReferenceField('Permissao', reverse_delete_rule=PULL))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions