diddi- / flask-seeder

Flask extension for seeding database
32 stars 11 forks source link

MongoEngine support #13

Closed ajesh-pb-ai closed 3 years ago

ajesh-pb-ai commented 3 years ago

Code, I have used from flask import Flask from flask_mongoengine import MongoEngine

app = Flask(__name__)

db = MongoEngine() db.init_app(app) seeder = FlaskSeeder() seeder.init_app(app, db)

Got Exception

flask_seeder/cli.py", line 182, in seed_run db.session.commit() AttributeError: 'MongoEngine' object has no attribute 'session'

ajesh-pb-ai commented 3 years ago

If I comment the line db.session.commit() in the package, Able to load the seeds succesfully.

diddi- commented 3 years ago

Flask-Seeder expects a db object with an SQLAlchemy session attribute to be able to commit any changes. db is typically an instance of Flask-SQLAlchemy which is what Flask-Seeder has been tested for and known to support. I'm not familiar with MongoEngine so I'm afraid I can't help you very much here but if you have a working solution for it that doesn't break existing functionality you're welcome to submit a PR.