I'm using PyQGIS/Python 2.7 on a Mac and trying to create a script (for the first time) which will read in a list of csv files and load them as layers. I'll want to define the style of the layers and then display them in the QGIS canvas. I am at the beginning stages of writing my script, shown below, and am executing it line-by-line using ipython. When I execute the app.initQgis() line, I get

    QSqlDatabase: QSQLITE driver not loaded  
    QSqlDatabase: available drivers:   
    ERROR: Opening of authentication db FAILED  
    QSqlQuery::prepare: database not open  
    WARNING: Auth db query exec() FAILED  

and when I execute the app.exitQgis() line, I get

    ERROR: Opening of authentication db FAILED

Is this some error/warning I should be concerned with and how do I fix this? I do not get the above responses when I execute these lines in the QGIS console.

Here is my script so far:

import os
import sys
from qgis.core import *
import qgis.utils

app = QgsApplication([], True)
QgsApplication.setPrefixPath("/Applications/QGIS.app/Contents/MacOS", True)


csv_filename = "/myDataPath/modRes_All_d20141118_t1813404_e1815046.csv"
uri = csv_filename + "?delimiter=%s&xField=%s&yField=%s" % ("\t", "lon", "lat")
csv_layer = QgsVectorLayer(uri, "csvmodRes", "delimitedtext")
if not csv_layer:
   print "CSV Layer failed to load!"



Your Answer

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

Browse other questions tagged or ask your own question.