[pysqlite] sqlite and python

massimo di stefano <[email protected]> Wed, 25 Mar 2009 12:36:43 +0100
Newsgroups gmane.comp.python.db.pysqlite.user,gmane.comp.python.apple
Message-ID <[email protected]>
--===============1449464128==
Content-Type: multipart/alternative; boundary=Apple-Mail-33--171717753


--Apple-Mail-33--171717753
Content-Type: text/plain;
	charset=US-ASCII;
	format=flowed;
	delsp=yes
Content-Transfer-Encoding: 7bit

Hi All,


i'm running python 2.5.1 on a mac osx 10.5.6 (the system pyrhon)
i've problems to enable spatialite extension [1]

in python using pysqlite2
maybe there are problems to enable the support for the dyn-extensions  
but i have no clue on how to fix it;

i downloaded the sources for pysqlite2 from :

https://launchpad.net/ubuntu/jaunty/+source/python-pysqlite2/2.5.0-2ubuntu1/+files/python-pysqlite2_2.5.0.orig.tar.gz

Unlucky on OSX, the pysqlite don't recognize the sqlite spatial  
extension :

these is the build log :

http://www.geofemengineering.it/data/pysqlite_build_log.txt.zip


tring it in python it don't works :


macbook-pro-15-di-sasha:pysqlite-2.5.0 sasha$ python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> from pysqlite2 import dbapi2 as sqlite
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "pysqlite2/dbapi2.py", line 27, in <module>
     from pysqlite2._sqlite import *
ImportError: No module named _sqlite
 >>>



while on linux i can symply do :

in the pysqlite source:

 > python setup.py build
 > sudo python setup.py install

and test it on a spatialite database [2]
downloaded from the spatialite sites test files:

i create a file :
test.py:
-------------
from pysqlite2 import dbapi2 as sqlite
DB = sqlite.connect('./test-2.3.sqlite');
DB.enable_load_extension(True);
DB.execute('SELECT load_extension("libspatialite.so")');
DBCursor = DB.cursor()
strSQL = 'SELECT Name, GeometryType(geometry), area(geometry) ';
strSQL += 'FROM regions ORDER BY Area(geometry) DESC';
DBCursor.execute( strSQL );
for row in DBCursor:
       print( row[0] + ' ' + row[1] + ' ' + str(row[2])
DBCursor.close();
DB.close();
---------------


running it :

 > python test.py
------------------
SICILIA MULTIPOLYGON 26074081211.3
PIEMONTE MULTIPOLYGON 25391974998.1
SARDEGNA MULTIPOLYGON 24125601024.3
LOMBARDIA MULTIPOLYGON 24069782849.5
TOSCANA MULTIPOLYGON 22971611856.6
EMILIA-ROMAGNA MULTIPOLYGON 22112626674.3
PUGLIA MULTIPOLYGON 19535533607.9
VENETO MULTIPOLYGON 18091146695.8
LAZIO MULTIPOLYGON 17075567463.4
CALABRIA MULTIPOLYGON 15357477642.6
CAMPANIA MULTIPOLYGON 13671884537.6
TRENTINO-ALTO ADIGE MULTIPOLYGON 13636192197.0
ABRUZZI MULTIPOLYGON 10921890033.0
BASILICATA MULTIPOLYGON 10082620411.6
MARCHE MULTIPOLYGON 9801006025.43
UMBRIA MULTIPOLYGON 8511757763.65
FRIULI-VENEZIA GIULIA MULTIPOLYGON 7571067911.64
LIGURIA MULTIPOLYGON 5451586208.43
MOLISE MULTIPOLYGON 4534700124.13
VALLE D'AOSTA MULTIPOLYGON 3309252833.27
SAN MARINO MULTIPOLYGON 60108921.7828
------------------

it works ....


[1] - http://www.gaia-gis.it/spatialite/index.html
[2] - test-2.3.7z



have you any suggestion on what i need to get it working on osx too ?
thanks a lot for any help!




Massimo Di Stefano
[email protected]

epifanio on   irc.freenode.net  /join gfoss









Massimo Di Stefano
[email protected]

epifanio on   irc.freenode.net  /join gfoss








--Apple-Mail-33--171717753
Content-Type: text/html;
	charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; "><div>Hi =
All,</div><div><br></div><div><br></div><div>i'm running python 2.5.1 on =
a mac osx 10.5.6 (the system pyrhon)</div><div>i've problems to enable =
spatialite&nbsp;extension&nbsp;[1]&nbsp;</div><div><br></div><div>in =
python using pysqlite2</div><div><div>maybe there are problems to enable =
the support for the dyn-extensions but i have no clue on how to fix =
it;</div><div><br>i downloaded the sources for pysqlite2 from =
:</div><div><br><a =
href=3D"https://launchpad.net/ubuntu/jaunty/+source/python-pysqlite2/2.5.0=
-2ubuntu1/+files/python-pysqlite2_2.5.0.orig.tar.gz">https://launchpad.net=
/ubuntu/jaunty/+source/python-pysqlite2/2.5.0-2ubuntu1/+files/python-pysql=
ite2_2.5.0.orig.tar.gz</a><br></div><div><br></div><div>Unlucky on OSX, =
the pysqlite don't recognize the sqlite spatial extension =
:</div><div><br></div><div>these is the build log =
:</div><div><br></div><div><div><span class=3D"Apple-style-span" =
style=3D"font-family: Arial; "><a =
href=3D"http://www.geofemengineering.it/data/pysqlite_build_log.txt.zip">h=
ttp://www.geofemengineering.it/data/pysqlite_build_log.txt.zip</a></span><=
/div></div><div><div></div><div><br></div><div><br></div><div>tring it =
in python it don't works =
:</div><div><br></div><div><br></div><div>macbook-pro-15-di-sasha:pysqlite=
-2.5.0 sasha$ python</div><div>Python 2.5.1 (r251:54863, Jan 13 2009, =
10:26:13)&nbsp;</div><div>[GCC 4.0.1 (Apple Inc. build 5465)] on =
darwin</div><div>Type "help", "copyright", "credits" or "license" for =
more information.</div><div>>>> from pysqlite2 import dbapi2 as =
sqlite</div><div>Traceback (most recent call =
last):</div><div>&nbsp;&nbsp;File "&lt;stdin>", line 1, in =
&lt;module></div><div>&nbsp;&nbsp;File "pysqlite2/dbapi2.py", line 27, =
in &lt;module></div><div>&nbsp;&nbsp; &nbsp;from pysqlite2._sqlite =
import *</div><div>ImportError: No module named =
_sqlite</div><div>>>>&nbsp;</div><div><br></div><div><br></div></div><div>=
<br></div><div><div>while on linux i can symply do =
:</div><div><br></div><div>in the pysqlite =
source:</div><div><br></div><div>> python setup.py build<br>> sudo =
python setup.py install<br><br>and test it on a spatialite database =
[2]</div><div>downloaded from the spatialite sites test files:<br><br>i =
create a file :</div><div>test.py:<br>-------------<br>from pysqlite2 =
import dbapi2 as sqlite<br>DB =3D =
sqlite.connect('./test-2.3.sqlite');<br>DB.enable_load_extension(True);<br=
>DB.execute('SELECT load_extension("libspatialite.so")');<br>DBCursor =3D =
DB.cursor()<br>strSQL =3D 'SELECT Name, GeometryType(geometry), =
area(geometry) ';<br>strSQL +=3D 'FROM regions ORDER BY Area(geometry) =
DESC';<br>DBCursor.execute( strSQL );<br>for row in =
DBCursor:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print( row[0] + ' ' + =
row[1] + ' ' + =
str(row[2])<br>DBCursor.close();<br>DB.close();<br>---------------<br><br>=
</div><div><br></div><div>running it :</div><div><br>> python =
test.py<br>------------------<br>SICILIA MULTIPOLYGON =
26074081211.3<br>PIEMONTE MULTIPOLYGON 25391974998.1<br>SARDEGNA =
MULTIPOLYGON 24125601024.3<br>LOMBARDIA MULTIPOLYGON =
24069782849.5<br>TOSCANA MULTIPOLYGON 22971611856.6<br>EMILIA-ROMAGNA =
MULTIPOLYGON 22112626674.3<br>PUGLIA MULTIPOLYGON =
19535533607.9<br>VENETO MULTIPOLYGON 18091146695.8<br>LAZIO MULTIPOLYGON =
17075567463.4<br>CALABRIA MULTIPOLYGON 15357477642.6<br>CAMPANIA =
MULTIPOLYGON 13671884537.6<br>TRENTINO-ALTO ADIGE MULTIPOLYGON =
13636192197.0<br>ABRUZZI MULTIPOLYGON 10921890033.0<br>BASILICATA =
MULTIPOLYGON 10082620411.6<br>MARCHE MULTIPOLYGON =
9801006025.43<br>UMBRIA MULTIPOLYGON 8511757763.65<br>FRIULI-VENEZIA =
GIULIA MULTIPOLYGON 7571067911.64<br>LIGURIA MULTIPOLYGON =
5451586208.43<br>MOLISE MULTIPOLYGON 4534700124.13<br>VALLE D'AOSTA =
MULTIPOLYGON 3309252833.27<br>SAN MARINO MULTIPOLYGON =
60108921.7828<br>------------------<br><br>it works =
.....</div><div><br></div></div><div><br></div><div><div>[1] -&nbsp;<a =
href=3D"http://www.gaia-gis.it/spatialite/index.html">http://www.gaia-gis.=
it/spatialite/index.html</a></div><div>[2] -&nbsp;<a =
href=3D"http://www.gaia-gis.it/QGisJanus/test-2.3.7z">test-2.3.7z</a></div=
><div><br></div><div><br></div><div><br></div></div><div>have you any =
suggestion on what i need to get it working on osx too =
?</div><div>thanks a lot for any =
help!</div><div><br></div><div><br></div><div><br></div><div><br></div><di=
v apple-content-edited=3D"true"><div style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><div style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div =
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><div>Massimo Di Stefano</div><div><a =
href=3D"mailto:[email protected]">[email protected]</a></div><=
div><br></div><div>epifanio on &nbsp;&nbsp;irc.freenode.net &nbsp;/join =
gfoss</div><div><br></div></div><div><br></div><div><br></div></div></div>=
</div></div></div></div></div><div><br></div><div><br></div><div><br></div=
><div><br></div><div><br></div><br><div apple-content-edited=3D"true"> =
<span class=3D"Apple-style-span" style=3D"border-collapse: separate; =
color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; =
font-style: normal; font-variant: normal; font-weight: normal; =
letter-spacing: normal; line-height: normal; orphans: 2; text-align: =
auto; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><div>Massimo Di Stefano</div><div><a =
href=3D"mailto:[email protected]">[email protected]</a></div><=
div><br></div><div>epifanio on &nbsp;&nbsp;irc.freenode.net &nbsp;/join =
gfoss</div><div><br></div></div></span><div><br></div><div><br></div><div>=
<br></div></div></span></div></span></div></span></div></span><br =
class=3D"Apple-interchange-newline"></div></span><br =
class=3D"Apple-interchange-newline"> </div><br></body></html>=

--Apple-Mail-33--171717753--
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


--===============1449464128==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
list-pysqlite mailing list
list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org
http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite
--===============1449464128==--
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com