Looking at the lines in app.py:
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
if app.config['SQLALCHEMY_DATABASE_URI']:
db = SQLAlchemy(app)
If you don't have the DATABASE_URL defined, then there will be no 'db' variable created which then cannot be imported in the createdb.py module. Can you check if you indeed have a value for os.environ.get('DATABASE_URL') ?