1
У меня возникла проблема при запуске приложения на Heroku. Локальная версия работает нормально, но я не могу позвонить create_db()
на платформу heroku.AttributeError: объект 'ParseResult' не имеет атрибута 'drivername'
Это ошибка.
(venv)S-MBP:LaunchPage3 S$ heroku run python
Running python on herokuapp... up, run.5609
Python 2.7.11 (default, Dec 7 2015, 21:16:24)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from app import db
>>> db.create_all()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 972, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 964, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 910, in get_engine
return connector.get_engine()
File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 542, in get_engine
self._sa.apply_driver_hacks(self._app, info, options)
File "/app/.heroku/python/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py", line 846, in apply_driver_hacks
if info.drivername.startswith('mysql'):
AttributeError: 'ParseResult' object has no attribute 'drivername'
Это app.py
import os, requests, json
from flask import Flask, render_template, request, redirect
import psycopg2, urlparse
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
if 'PRODUCTION' in os.environ:
urlparse.uses_netloc.append("postgres")
app.config['SQLALCHEMY_DATABASE_URI'] = urlparse.urlparse(os.environ["DATABASE_URL"])
else:
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:[email protected]:5432/db'
app.config['SQLALCHEMY_ECHO'] = True
db = SQLAlchemy(app)
[CODE - ONE FILE APPLICATION WITH DB MODELS ETC]
if __name__ == '__main__':
db.create_all()
port = int(os.environ.get('PORT',5000))
if 'PRODUCTION' in os.environ:
app.debug = False
app.run(host='0.0.0.0', port=port)
else:
app.debug = True
app.run(host='127.0.0.1', port=port)
Все указатели будут оценены. Я пробовал следовать за other question в SO, но эти ответы не помогли.