简体   繁体   中英

Flask-migrate makes SQLite migration instead of PSQL

Hi I've exported in virtualenv database with command

export DATABASE_URL="postgresql://localhost/dbname"

But after running

python manage.py init

and

python manage.py db migrate

Result is:

INFO  [alembic.runtime.migration] Context impl SQLiteImpl.

PostreSQL database have been previously created and SQLAlchemy URI have been set in config.py file. During migration i have opened psql db in another terminal window (in the venv) with commands

psql

and then

\c dbname

How can I connect to the PSQL db?

You do not have the correct connection string. The format is

dialect+driver://username:password@host:port/database

So yours should be

postgresql://username:password@localhost:5432/dbname

Source: https://docs.sqlalchemy.org/en/13/core/engines.html#database-urls

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM