[GRASS-SVN] r38785 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Aug 19 03:38:35 EDT 2009
Author: hamish
Date: 2009-08-19 03:38:34 -0400 (Wed, 19 Aug 2009)
New Revision: 38785
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py
Log:
double-quotes for WinGrass;
fix access tables not in the current mapset;
skip the non-column lines of db.describe -c;
fix os.popen usage and quote DB (needs conversion to gcmd.RunCommand);
quote DB in os.system (needs conversion to gcmd.RunCommand)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py 2009-08-19 06:57:25 UTC (rev 38784)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/sqlbuilder.py 2009-08-19 07:38:34 UTC (rev 38785)
@@ -52,7 +52,7 @@
self.vectmap = self.vectmap + "@" + grass.gisenv()['MAPSET']
self.mapname, self.mapset = self.vectmap.split("@")
self.layer,self.tablename, self.column, self.database, self.driver =\
- os.popen("v.db.connect -g fs='|' map=%s" %\
+ os.popen("v.db.connect -g fs=\"|\" map=%s" %\
(self.vectmap)).readlines()[0].strip().split("|")
self.qtype = qtype # type of the uqery: SELECT, UPDATE, DELETE, ...
@@ -224,10 +224,16 @@
quiet = True,
read = True,
flags = 'c',
- table = self.tablename)
+ table = self.tablename,
+ database = self.database,
+ driver = self.driver)
- # skip ncols and nrows lines
for line in ret.splitlines():
+ # skip ncols and nrows lines
+ linetype = line.strip().split(":")[0]
+ if linetype == "ncols" or linetype == "nrows":
+ continue
+
num, name, ctype, length = line.strip().split(":")
name.strip()
#self.columns_names.append(name)
@@ -243,7 +249,7 @@
self.list_values.Clear()
column = self.list_columns.GetString(idx)
i = 0
- for line in os.popen("""!db.select -c database=%s driver=%s sql="SELECT %s FROM %s" """ %\
+ for line in os.popen("db.select -c database=\"%s\" driver=%s sql=\"SELECT %s FROM %s\"" %\
(self.database,self.driver,column,self.tablename)):
if justsample and i < 256 or \
not justsample:
@@ -314,7 +320,7 @@
pass
def OnVerify(self,event):
if self.text_sql.GetValue():
- if os.system("""!db.select -t driver=%s database=%s sql="SELECT * FROM %s WHERE %s" """ % \
+ if os.system("""!db.select -t driver=%s database="%s" sql="SELECT * FROM %s WHERE %s" """ % \
(self.driver, self.database,self.tablename,
self.text_sql.GetValue().strip().replace("\n"," "))):
# FIXME: LOG
More information about the grass-commit
mailing list