from flask.ext.script import Manager, prompt_bool from api import app, db, esales from api.models import Designer manager = Manager(app) @manager.command def init_db(): db.create_all() print("All tables created") @manager.command def drop_db(): if prompt_bool("Are you sure you want to lose all your data?"): db.drop_all() print("All tables dropped") @manager.command def seed_db(): print("Adding sample data") designer = Designer(name="Martin", path='/martin') db.session.add(designer) db.session.commit() @manager.command def run_esales_import(): print("Importing products and categories into eSales") pattern = "{}/*.xml".format(app.config.get("ESALES_IMPORT_DIR")) esales.import_products_and_categories(pattern) if __name__ == '__main__': manager.run()