python - MongoEngine change database -


due project setup (same flasky) , when run python tests (line 34), connection development database created, before configuration set test (line 11 here). results in problems tests, since meant run on clean db.

looking online, found descriptions of switch_db not need. need either change database connection using, or drop connection , create new one. cant find way either of these.. missing ? connection initialized using line of code, inside init.py of main app directory.

from mongoengine import connection db_name = 'name_from_config' connection(db_name) 

you should avoid creating connection mongoengine in way describe precisely reason. flasky using application factory approach allows application know connection config use when implementing data models.

the best way integrate mongoenigne app flask-mongoengine should solve problem out-of-the-box.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -