Using Python code in my plugin the function in sql language "GeomFromText(POINT(X Y))" gives the following error: "OperationalError: no such function: GeomFromText" Plugin functions in previous versions of QGIS.

  • 1
    This question in it's current state is not understandable. Where are you running this function? Do you have a spatialite database? what have you tried so far? Please see this post for tips on how you could improve this question: meta.gis.stackexchange.com/questions/3349/… – Devdatta Tengshe Sep 3 '15 at 11:14
  • This is a portion af code:conn = sqlite3.connect(database) ----- c = conn.cursor() ----- insert = 'INSERT INTO ' + shape_punto + ' (PKUID, Geometry) VALUES (NULL, GeomFromText(\"POINT(' + str(XX) + ' ' + str(YY) + ')\", 32632))' ----- c.execute(insert) ---- conn.commit() – Giuseppe Stella Sep 3 '15 at 12:19
  • Can you try to put all of the detail into the question? In particular, can you say which version(s) of spatialite you have loaded, and perhaps show a more complete example? Just click edit below the question. – BradHards Sep 9 '15 at 9:28
  • Until the release of QGIS 2.8.1 sql function was performed properly. Later versions have the indicated error. The database spatialite is the same and the python code is the same. SQLite version 3.7.17. SpatiaLite version 4.1.1 – Giuseppe Stella Sep 9 '15 at 9:54

First you need to load the spatialite extension. On linux:

expr = "SELECT load_extension('libspatialite');"

Now your insert should succeed. On Windows it;s similar, but with the full DLL name. Check this answer.

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.