1

I'm making PostGIS queries to a GIS database from python and I'm using QGIS to visually check the results of my queries, but every time I want to run a new query I have to close QGIS because it keeps its database connection open. Do you have any idea how to force QGIS to disconnect from the database without closing it every time?

1

Which version of QGIS are you running? I used to encounter this all the time, but haven't since switching to QGIS 2.4. I suspect it's been fixed.

One workaround which I used to use was that instead of closing QGIS you can use pgAdmin to just temporarily terminate the open blocking connection from QGIS. Go to Tools -> Server Status, select the connection from the "activity" list, and select Action -> Terminate Backend. Generally this used to work OK, as QGIS would just create a new connection when required.

1

If you are using psycopg2 then you can close the connection to Postgres like so con.close()

1

a thread from last year on osgeo mentions 'if you are using the PostGIS Manager you have the option to refresh...'. However, PostGIS Manager has been superseded by DB Manager. I don't have a PostGIS database to test, but DB Manager allows refresh of sqlite databases. Still could be a bit of a pain if you have to open DB Manager, select the db, and hit F5 each time a new query is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.