|
@@ -43,10 +43,6 @@
|
|
#%end
|
|
#%end
|
|
#%option G_OPT_DB_WHERE
|
|
#%option G_OPT_DB_WHERE
|
|
#%end
|
|
#%end
|
|
-#%option G_OPT_F_INPUT
|
|
|
|
-#% key: sqliteextra
|
|
|
|
-#% description: Name of libsqlitefunctions file for extra functions (SQLite backend only)
|
|
|
|
-#%end
|
|
|
|
|
|
|
|
import sys
|
|
import sys
|
|
import os
|
|
import os
|
|
@@ -59,7 +55,6 @@ def main():
|
|
value = options['value']
|
|
value = options['value']
|
|
qcolumn = options['qcolumn']
|
|
qcolumn = options['qcolumn']
|
|
where = options['where']
|
|
where = options['where']
|
|
- sqlitefile = options['sqliteextra']
|
|
|
|
|
|
|
|
mapset = grass.gisenv()['MAPSET']
|
|
mapset = grass.gisenv()['MAPSET']
|
|
|
|
|
|
@@ -76,13 +71,6 @@ def main():
|
|
database = f['database']
|
|
database = f['database']
|
|
driver = f['driver']
|
|
driver = f['driver']
|
|
|
|
|
|
- # check for SQLite backend for extra functions
|
|
|
|
- if sqlitefile and driver != "sqlite":
|
|
|
|
- grass.fatal(_("Use of libsqlitefunctions only with SQLite backend"))
|
|
|
|
- if driver == "sqlite" and sqlitefile:
|
|
|
|
- if not os.access(sqlitefile, os.R_OK):
|
|
|
|
- grass.fatal(_("File <%s> not found") % sqlitefile)
|
|
|
|
-
|
|
|
|
# checking column types
|
|
# checking column types
|
|
try:
|
|
try:
|
|
coltype = grass.vector_columns(vector, layer)[column]['type']
|
|
coltype = grass.vector_columns(vector, layer)[column]['type']
|
|
@@ -105,12 +93,8 @@ def main():
|
|
if where:
|
|
if where:
|
|
cmd += " WHERE " + where
|
|
cmd += " WHERE " + where
|
|
|
|
|
|
- # SQLite: allow for extra functions if provided by user
|
|
|
|
- if sqlitefile:
|
|
|
|
- sqliteload = "SELECT load_extension('%s');\n" % sqlitefile
|
|
|
|
- cmd = sqliteload + cmd + ";\n"
|
|
|
|
-
|
|
|
|
grass.verbose("SQL: \"%s\"" % cmd)
|
|
grass.verbose("SQL: \"%s\"" % cmd)
|
|
|
|
+
|
|
grass.write_command('db.execute', input = '-', database = database, driver = driver, stdin = cmd)
|
|
grass.write_command('db.execute', input = '-', database = database, driver = driver, stdin = cmd)
|
|
|
|
|
|
# write cmd history:
|
|
# write cmd history:
|