@@ -590,38 +590,33 @@ def startServerPlugin(packageName):
590
590
591
591
def spatialite_connect (* args , ** kwargs ):
592
592
"""returns a dbapi2.Connection to a SpatiaLite db
593
- either using pyspatialite if it is present
594
- or using the "mod_spatialite" extension (python3)"""
595
- try :
596
- from pyspatialite import dbapi2
597
- except ImportError :
598
- import sqlite3
599
- con = sqlite3 .dbapi2 .connect (* args , ** kwargs )
600
- con .enable_load_extension (True )
601
- cur = con .cursor ()
602
- libs = [
603
- # SpatiaLite >= 4.2 and Sqlite >= 3.7.17, should work on all platforms
604
- ("mod_spatialite" , "sqlite3_modspatialite_init" ),
605
- # SpatiaLite >= 4.2 and Sqlite < 3.7.17 (Travis)
606
- ("mod_spatialite.so" , "sqlite3_modspatialite_init" ),
607
- # SpatiaLite < 4.2 (linux)
608
- ("libspatialite.so" , "sqlite3_extension_init" )
609
- ]
610
- found = False
611
- for lib , entry_point in libs :
612
- try :
613
- cur .execute ("select load_extension('{}', '{}')" .format (lib , entry_point ))
614
- except sqlite3 .OperationalError :
615
- continue
616
- else :
617
- found = True
618
- break
619
- if not found :
620
- raise RuntimeError ("Cannot find any suitable spatialite module" )
621
- cur .close ()
622
- con .enable_load_extension (False )
623
- return con
624
- return dbapi2 .connect (* args , ** kwargs )
593
+ using the "mod_spatialite" extension (python3)"""
594
+ import sqlite3
595
+ con = sqlite3 .dbapi2 .connect (* args , ** kwargs )
596
+ con .enable_load_extension (True )
597
+ cur = con .cursor ()
598
+ libs = [
599
+ # SpatiaLite >= 4.2 and Sqlite >= 3.7.17, should work on all platforms
600
+ ("mod_spatialite" , "sqlite3_modspatialite_init" ),
601
+ # SpatiaLite >= 4.2 and Sqlite < 3.7.17 (Travis)
602
+ ("mod_spatialite.so" , "sqlite3_modspatialite_init" ),
603
+ # SpatiaLite < 4.2 (linux)
604
+ ("libspatialite.so" , "sqlite3_extension_init" )
605
+ ]
606
+ found = False
607
+ for lib , entry_point in libs :
608
+ try :
609
+ cur .execute ("select load_extension('{}', '{}')" .format (lib , entry_point ))
610
+ except sqlite3 .OperationalError :
611
+ continue
612
+ else :
613
+ found = True
614
+ break
615
+ if not found :
616
+ raise RuntimeError ("Cannot find any suitable spatialite module" )
617
+ cur .close ()
618
+ con .enable_load_extension (False )
619
+ return con
625
620
626
621
627
622
class OverrideCursor ():
0 commit comments