def ensure_db_exists(): ''' Tell Flask to create the database which is configured if it doesn't exist ''' filepath = app.config.get('FEEDER_DATABASE', './feeder.db') filepath = os.path.abspath(filepath) if not os.path.isfile(filepath): from feeder.database import db db.create_all() print("Database was created successfully")
def ensure_db_exists(): ''' Tell Flask to create the database which is configured if it doesn't exist ''' import feeder.rest from feeder.database import app, db filepath = app.config.get('FEEDER_DATABASE', '/var/lib/feeder/feeder.db') filepath = os.path.abspath(filepath) if not os.path.isfile(filepath): print("Ensuring database") db.create_all() print("Database was created successfully")
# -*- coding: utf-8 -*- ''' Usage python createdb.py -c /path/to/config.yaml Creates the database whose location is specified by the config file. See config-sample.yaml for details. ''' import sys from feeder import read_config if __name__ == '__main__': if len(sys.argv) != 3 or sys.argv[1] != '-c': exit(__doc__) configfile = sys.argv[2] read_config(configfile) import feeder.rest from feeder.database import db db.create_all() exit("Database created successfully")