The PostGIS database is remote but I have made changes to the Postgresql config files and can access it remotely via pgadmin.

When I open DBmanager in QGIS I see a note on the bottom that says "postgis:No module named psycopg2." I can't find anyway to connect to the database through the GUI.

I have been able to connect to the database in QGIS using the SPIT plugin, though when I try to import layers it returns the following error: "Problem inserting features from file /path/to/shape/file.shp Invalid table name."

I can get the data from QGIS to the server by ftping the files to the server and then importing them with the shp2pgsql command. I can then download the data back into PostGIS without a problem, so I know the database is working properly.

What I want though is to be able to import QGIS layers to the PostGIS database from within QGIS.

Please forgive my ignorance. I'm learning this stuff as I go. Any clues you can provide will be much appreciated.

I've looked at the answer here: psycopg2 error with QGIS 1.5. I might be missing something, but it didn't help me. That answer explains how to config Windows registry keys, but I'm running QGIS on OSX and the database server is running on Debian (stable), so I don't have registry keys.

  • You are lacking the python module psycopg2. SPIT could be failing because "file" is a reserved word and cannot be used as a table name - but that's only a theory. – underdark Mar 3 '13 at 9:44
  • Thanks for the help. Do you mean install psycopg2 on OSX (where QGIS is)? I have installed it on my Debain machine (where the PostGIS database is), but it didn't change anything. How do I change the table name in SPIT? – Joel Legassie Mar 3 '13 at 17:47
  • Yes, it would be needed on the QGIS machine – underdark Mar 3 '13 at 17:53
  • I've started looking into installing psycopg2, and it seems that I would have to first install PostgreSQL on OSX (which I don't need) and then psycopg2, which would require me to install Xcode, and either Fink or Macports, unless I choose to compile the psycopg2 binary myself, (I'd rather not). I'm not sure if I want to go to all that trouble. Is there an easier way? Regarding SPIT, how do I change the table name? or even see what it is? Is it the same as the name of the QGIS layer I'm trying to upload to the remote database? – Joel Legassie Mar 8 '13 at 21:31
  • I managed to import layers to the remote database using SPIT. Turns out the problem was my shape file filenames began with numbers. When I put a letter in front of the number it imported without problems. Thanks for the help @underdark – Joel Legassie Mar 8 '13 at 21:44

Your Answer

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

Browse other questions tagged or ask your own question.