Reputation: 3
Trying to insert a GeoDataFrame with geometry variables to SQLite, I get the following error:
in enable_spatialite_extension raise LoadExtensionError(msg) from error spatialite.connection.LoadExtensionError: Failed to load Spatialite extension. Verify that your python module sqlite3 has load extension support and check that libspatialite is installed. Tried extension names: mod_spatialite, mod_spatialite.so, mod_spatiaite.dylib
I am running my code on WayScript (IDE), and I do not know how to install this module properly, even nor how to locate mod_spatialite.dll file in a folder that is in the system path.
This is my code:
# Create the database connection
connection = sqlite3.connect('database.db')
# Export data to database
data.to_sql('database', con=connection, if_exists='replace', index=False)
# Add a new table column to store the geometry data
cursor = connection.cursor()
cursor.enable_load_extension(True)
cursor.load_extension("mod_spatialite")
cursor.execute("SELECT InitSpatialMetaData(1);")
cursor.execute(
"""
SELECT AddGeometryColumn('database', 'wkb_geometry', 4326, 'POLYGON', 2);
"""
)
Upvotes: 0
Views: 769
Reputation: 273
You need to pip install <package>
in the WayScript terminal and then input pip freeze > requirements.txt
into the terminal.
Here is a link to WayScript's docs on the matter.
Upvotes: 0