0

Getting the following error when trying to run. Just recently trying to move from SQLite to PostGres on Flask so that I can host on Heroku.

 File "XXXXXX/Desktop/hubbub/flask/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 377, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "/Users/jianglin/Desktop/hubbub/flask/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: (OperationalError) FATAL:  database "XXXXX/Desktop/hubbub/app.db" does not exist
 None None

I have been using the following tutorial thus far for most my database stuff: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iv-database

Sorry if this is a basic question, I am new to the world of Flask. My guess is this has something to do with me not creating the database, but I am not sure how given the format of this tutorial. trying to create via db_create gives me the same error.

1 Answer 1

1

The part of your error message that is important is probably this:

FATAL: database "XXXXX/Desktop/hubbub/app.db" does not exist

An ending in .db is usually something you would do with SQLite, not with Postgres. Try looking for wherever you specify the database settings and change it to the correct setting for Heroku's DB instance. Note: while SQLite can be specified with just a file location, Postgres needs to have username/password/location/database information. Here is a sample:

SQLALCHEMY_DATABASE_URI = "postgresql://yourusername:yourpassword@localhost/yournewdb"
Sign up to request clarification or add additional context in comments.

3 Comments

so I changed it to the given format you specified but it gives the same error except conn = _connect(dsn, connection_factory=connection_factory, async=async) sqlalchemy.exc.OperationalError: (OperationalError) FATAL: database "yournewdb" does not exist
Thanks for your initial comment btw, I am sure that was part of my problem
@user3525295: We're getting somewhere at least. You need to use the connection details given from Heroku in that string, not the example. "yournewdb" is the database name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.