[Qgis-user] QGIS plugin with python

Emilio S emiliosjlc at hotmail.com
Fri Oct 23 09:54:00 PDT 2015


Thank you and sorry.I have tried to connect to spatialite with this code, but this doesn´t add anything. Could you know why?

from PyQt4.QtCore import *from PyQt4.QtGui import *uri=QgsDataSourceURI()uri.setDatabase('C:\Users\pr\Desktop\GIS.sqlite')schema=' 'table ='ambi'geom_column= 'geom'uri.setDataSource(schema, table, geom_column)display_name=('prueba')vlayer=QgsVectorLayer(uri.uri(), display_name, 'spatialite')

Thanks

Subject: Re: QGIS plugin with python
To: emiliosjlc at hotmail.com; qgis-user at lists.osgeo.org
From: wal3 at mindspring.com
Date: Fri, 23 Oct 2015 09:29:13 -0400


  
    
  
  
    Emilio,

    

    Please reply to the QGIS users list so others will benefit from the
    discussion.  :)

    

    Your next reading would probably be the QT4 and PyQt4 documentation
    for the SQL database classes. 

    QT4 is the c++ version of the code.  

    

    PyQt4 is the python wrappers around QT4.

    

    While you will be coding in python, the c++ documentation may be
    helpful and clearer to read.

    

    Google has been my friend.  :)

    

    Here are a few links to get you started.

    

    http://doc.qt.io/qt-4.8/sql-connecting.html

    http://pyqt.sourceforge.net/Docs/PyQt4/index.html

    http://pyqt.sourceforge.net/Docs/PyQt4/qsqldatabase.html

http://stackoverflow.com/questions/7669987/what-is-the-correct-way-of-qsqldatabase-qsqlquery

    

    I'm sorry don't have an example available at the moment. I cannot
    promise I'll find the time to put one together.

    

    Worth Lutz

      

      

    
    On 10/23/2015 8:47 AM, Emilio S wrote:

    
    
      
      Thank you Worth Luz for your explanation. I have
        started with this and I have read a lot, but do you know any
        example to conect python with spatialite and do a SQL query?
        

        
        Thank you again
      
    
    
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20151023/da57b943/attachment.html>


More information about the Qgis-user mailing list