@@ -55,7 +55,6 @@ def __init__(self, uri):
55
55
56
56
self ._checkSpatial ()
57
57
self ._checkRaster ()
58
- self ._checkGeopackage ()
59
58
60
59
def _connectionInfo (self ):
61
60
return str (self .dbname )
@@ -92,11 +91,6 @@ def _checkRaster(self):
92
91
self .has_raster = self ._checkRasterTables ()
93
92
return self .has_raster
94
93
95
- def _checkGeopackage (self ):
96
- """ check if it's a geopackage db """
97
- self .is_gpkg = self ._checkGeopackageTables ()
98
- return self .is_gpkg
99
-
100
94
def _checkGeometryColumnsTable (self ):
101
95
try :
102
96
c = self ._get_cursor ()
@@ -118,36 +112,6 @@ def _checkRasterTables(self):
118
112
ret = c .fetchone ()
119
113
return ret and ret [0 ]
120
114
121
- def _checkGeopackageTables (self ):
122
- try :
123
- sql = u"SELECT HasGeoPackage()"
124
- result = self ._execute (None , sql ).fetchone ()[0 ] == 1
125
- except ConnectionError :
126
- result = False
127
- except Exception :
128
- # SpatiaLite < 4.2 does not have HasGeoPackage() function
129
- result = False
130
-
131
- if result :
132
- try :
133
- sql = u"SELECT CheckGeoPackageMetaData()"
134
- result = self ._execute (None , sql ).fetchone ()[0 ] == 1
135
- except ConnectionError :
136
- result = False
137
- else :
138
- # Spatialite < 4.2 has no GeoPackage support, check for filename and GPKG layout
139
- ver = list (map (int , self .getInfo ()[0 ].split ('.' )[0 :2 ]))
140
- if ver [0 ] < 4 or (ver [0 ] == 4 and ver [1 ] < 2 ):
141
- hasGpkgFileExt = self .dbname [- 5 :] == ".gpkg" or self .dbname [- 11 :] == ".geopackage"
142
-
143
- sql = u"SELECT count(*) = 3 FROM sqlite_master WHERE name IN ('gpkg_geometry_columns', 'gpkg_spatial_ref_sys', 'gpkg_contents')"
144
- ret = self ._execute (None , sql ).fetchone ()
145
- hasGpkgLayout = ret and ret [0 ]
146
-
147
- result = hasGpkgFileExt and hasGpkgLayout
148
-
149
- return result
150
-
151
115
def getInfo (self ):
152
116
c = self ._get_cursor ()
153
117
self ._execute (c , u"SELECT sqlite_version()" )
@@ -159,7 +123,7 @@ def getSpatialInfo(self):
159
123
- geos version
160
124
- proj version
161
125
"""
162
- if not self .has_spatial and not self . is_gpkg :
126
+ if not self .has_spatial :
163
127
return
164
128
165
129
c = self ._get_cursor ()
@@ -187,9 +151,6 @@ def hasTableColumnEditingSupport(self):
187
151
def hasCreateSpatialViewSupport (self ):
188
152
return True
189
153
190
- def isGpkg (self ):
191
- return self .is_gpkg
192
-
193
154
def fieldTypes (self ):
194
155
return [
195
156
"integer" , "bigint" , "smallint" , # integers
@@ -307,14 +268,6 @@ def getVectorTables(self, schema=None):
307
268
WHERE m.type in ('table', 'view')
308
269
ORDER BY m.name, g.f_geometry_column""" % cols
309
270
310
- elif self .is_gpkg :
311
- # get info from gpkg_geometry_columns table
312
- dim = " 'XY' || CASE z WHEN 1 THEN 'Z' END || CASE m WHEN 1 THEN 'M' END AS coord_dimension "
313
- sql = u"""SELECT m.name, m.type = 'view', g.table_name, g.column_name, g.geometry_type_name AS gtype, %s, g.srs_id
314
- FROM sqlite_master AS m JOIN gpkg_geometry_columns AS g ON upper(m.name) = upper(g.table_name)
315
- WHERE m.type in ('table', 'view')
316
- ORDER BY m.name, g.column_name""" % dim
317
-
318
271
else :
319
272
return []
320
273
@@ -340,8 +293,6 @@ def getRasterTables(self, schema=None):
340
293
srid
341
294
"""
342
295
343
- if self .is_gpkg :
344
- return [] # Not implemented
345
296
if not self .has_geometry_columns :
346
297
return []
347
298
if not self .has_raster :
@@ -447,10 +398,7 @@ def getViewDefinition(self, view):
447
398
return ret [0 ] if ret is not None else None
448
399
449
400
def getSpatialRefInfo (self , srid ):
450
- if self .is_gpkg :
451
- sql = u"SELECT srs_name FROM gpkg_spatial_ref_sys WHERE srs_id = %s" % self .quoteString (srid )
452
- else :
453
- sql = u"SELECT ref_sys_name FROM spatial_ref_sys WHERE srid = %s" % self .quoteString (srid )
401
+ sql = u"SELECT ref_sys_name FROM spatial_ref_sys WHERE srid = %s" % self .quoteString (srid )
454
402
c = self ._execute (None , sql )
455
403
ret = c .fetchone ()
456
404
return ret [0 ] if ret is not None else None
@@ -503,8 +451,6 @@ def deleteTable(self, table):
503
451
""" delete table from the database """
504
452
if self .isRasterTable (table ):
505
453
return False
506
- if self .is_gpkg :
507
- return False # Not implemented
508
454
509
455
c = self ._get_cursor ()
510
456
sql = u"DROP TABLE %s" % self .quoteId (table )
@@ -518,8 +464,6 @@ def emptyTable(self, table):
518
464
""" delete all rows from table """
519
465
if self .isRasterTable (table ):
520
466
return False
521
- if self .is_gpkg :
522
- return False # Not implemented
523
467
524
468
sql = u"DELETE FROM %s" % self .quoteId (table )
525
469
self ._execute_and_commit (sql )
@@ -532,8 +476,6 @@ def renameTable(self, table, new_table):
532
476
533
477
if self .isRasterTable (table ):
534
478
return False
535
- if self .is_gpkg :
536
- return False # Not implemented
537
479
538
480
c = self ._get_cursor ()
539
481
@@ -573,8 +515,6 @@ def renameView(self, view, new_name):
573
515
return self .renameTable (view , new_name )
574
516
575
517
def createSpatialView (self , view , query ):
576
- if self .is_gpkg :
577
- return False # Not implemented
578
518
579
519
self .createView (view , query )
580
520
# get type info about the view
@@ -654,8 +594,6 @@ def setColumnNull(self, table, column, is_null):
654
594
return False # column editing not supported
655
595
656
596
def isGeometryColumn (self , table , column ):
657
- if self .is_gpkg :
658
- return False # Not implemented
659
597
660
598
c = self ._get_cursor ()
661
599
schema , tablename = self .getSchemaTableName (table )
@@ -665,8 +603,6 @@ def isGeometryColumn(self, table, column):
665
603
return c .fetchone ()[0 ] == 't'
666
604
667
605
def addGeometryColumn (self , table , geom_column = 'geometry' , geom_type = 'POINT' , srid = - 1 , dim = 2 ):
668
- if self .is_gpkg :
669
- return False # Not implemented
670
606
671
607
schema , tablename = self .getSchemaTableName (table )
672
608
sql = u"SELECT AddGeometryColumn(%s, %s, %d, %s, %s)" % (
@@ -704,8 +640,6 @@ def deleteTableIndex(self, table, name):
704
640
def createSpatialIndex (self , table , geom_column = 'geometry' ):
705
641
if self .isRasterTable (table ):
706
642
return False
707
- if self .is_gpkg :
708
- return False # Not implemented
709
643
710
644
schema , tablename = self .getSchemaTableName (table )
711
645
sql = u"SELECT CreateSpatialIndex(%s, %s)" % (self .quoteString (tablename ), self .quoteString (geom_column ))
@@ -714,8 +648,6 @@ def createSpatialIndex(self, table, geom_column='geometry'):
714
648
def deleteSpatialIndex (self , table , geom_column = 'geometry' ):
715
649
if self .isRasterTable (table ):
716
650
return False
717
- if self .is_gpkg :
718
- return False # Not implemented
719
651
720
652
schema , tablename = self .getSchemaTableName (table )
721
653
try :
@@ -729,8 +661,6 @@ def deleteSpatialIndex(self, table, geom_column='geometry'):
729
661
self .deleteTable (idx_table_name )
730
662
731
663
def hasSpatialIndex (self , table , geom_column = 'geometry' ):
732
- if self .is_gpkg :
733
- return False # Not implemented
734
664
if not self .has_geometry_columns or self .isRasterTable (table ):
735
665
return False
736
666
c = self ._get_cursor ()
0 commit comments