ソースを参照

merge from devbr6-
double-quotes for WinGrass;
access tables not in the current mapset;
skip 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)


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38786 15284696-431f-4ddb-bdfa-cd5b030d7da7

Hamish Bowman 15 年 前
コミット
c0259e04cb
1 ファイル変更11 行追加5 行削除
  1. 11 5
      gui/wxpython/gui_modules/sqlbuilder.py

+ 11 - 5
gui/wxpython/gui_modules/sqlbuilder.py

@@ -52,7 +52,7 @@ class SQLFrame(wx.Frame):
             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 @@ class SQLFrame(wx.Frame):
                               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 @@ class SQLFrame(wx.Frame):
         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 @@ class SQLFrame(wx.Frame):
                 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