From: Eric Hodel Date: 2009-06-24T17:53:34+09:00 Subject: Re: How to connect to SpatiaLite, a spatial enabled sqlite3 db? Don't top post. On Jun 24, 2009, at 00:46, Jan Martin wrote: > Eric Hodel wrote: >> On Jun 23, 2009, at 23:18, Jan Martin wrote: >>> I am a beginner making a decision on what programing language I >>> spent >>> more time to learn it. >>> In principle I really really like ruby. >>> >>> However for a GIS project of mine I like to use spatialite, a sqlite >>> database with spatial extension: >>> http://www.gaia-gis.it/spatialite/ >>> >>> And it seems there is no way to interface it from ruby? >> >> From your python code below, it seems to be plain old SQL. >> >>> def index(req): >>> data = util.FieldStorage(req) >>> lat= data['lat']; >>> lon= data['lon']; >>> >>> DB = sqlite.connect('exif.sqlite'); >>> DB.enable_load_extension(True); >>> DB.execute('SELECT load_extension("libspatialite.so")'); >> >> Looks like the ruby equivalent method to this DB.execute would be >> SQLite3::Database#execute, which should handle the same SQL syntax. >> >>> );" >>> >>> DBCursor.execute( strSQL ); >> >> Ditto. > > I gave it a try. > However it seems all the spatial functionality does not work. > And thats what I need. > Check the "db.execute" lines. > > Any ideas? > > Thanks, > Jan > #!/usr/bin/env ruby > > require 'rubygems' > require 'sqlite3' > > db = SQLite3::Database.new( "exif.sqlite" ) > > # Does NOT work: > db.execute( "SELECT Y(GpsGeometry), > X(GpsGeometry),DateTime(GpsTimestamp), FromPath FROM ExifPhoto" ) do > |row| You haven't loaded the geometry extension like you did in the python script.