-2

In my flask application I used Sqlite for Test Now I want to change it to postgresql But Got error OperationalError: (OperationalError) FATAL: database "mytest" does not exist None None am I doing it Right? where is the problem , Thanx

config.py:

class TestingConfig(Config):
    DEBUG = True
    TESTING = True
    PRESERVE_CONTEXT_ON_EXCEPTION = False
    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
    os.environ.get('DATABASE_URL','postgresql+psycopg2://admin:password@localhost/mytest')
    print SQLALCHEMY_DATABASE_URI
LiLi
  • 301
  • 2
  • 7
  • 21
  • As the message says: the database `mytest` does not exist on the PostgreSQL server, you have to create it: http://www.postgresql.org/docs/9.0/static/sql-createdatabase.html – Klaus D. Mar 03 '15 at 10:32
  • thanx I try to connect to mytest with command psql mytest but said psql: FATAL: database "mytest" does not exist even though I create it in Config.py @KlausD. – LiLi Mar 03 '15 at 10:41
  • You have to create it on the database server! Otherwise config.py just point at a non-existing database. – Klaus D. Mar 03 '15 at 10:49

1 Answers1

-1

As the error says, there is no database called "mytest" on the PostgreSQL server you're pointing to. Unlike SQLite which will create a file for the database if it doesn't exist, with PostgreSQL you need to create the database on the server before using it. Assuming PostgreSQL is otherwise set up properly, from the terminal (not the Python shell) run:

createdb mytest
davidism
  • 121,510
  • 29
  • 395
  • 339