Skip to content

"MySQL Server has gone away" error due to implementation #2

@VimanyuAgg

Description

@VimanyuAgg

Is there any reason why session_factory method includes the create_all() statement? Why not use the create_all() globally just below Base is created?

def session_factory():
    Base.metadata.create_all(engine) # why is this a part of session_factory
    return _SessionFactory()

I'm using sqlalchemy with my Flask application and getting intermittent "MySQL server has gone away" error on the create_all() line. I believe due to inactivity Base doesn't exist anymore. Your thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions