Performance problems using Sqlite function InitSpatialMetaData() to create a Spatialite database through Python

gis, python, spatialite, sqlite

Solution

This is an old question, but per this thread on gdal-dev, and depending on your version of the library,

InitSpatialMetadata(1) // Note the parameter

might run much faster. It did for me.

Problem

I'm creating a dynamic database through python. The code above work's fine but when I use the function InitSpatialMetadata() in query, the database is created very slowly. The file starts with 0kb and it's increases something like 2-5kb per second until it is completely create. All the process takes about 2-3 minutes to complete and the final file has 3mb. Someone already had this problem? ``` import sqlite3 db = sqlite3.connect('C:/test.sqlite') cursor = db.cursor() cursor.execute("SELECT InitSpatialMetadata()") ```

Original source