Mercurial > hg > ChinaGisRestApi
comparison RestDbInterface.py @ 53:f5bfcfa97e7e
more JSON store
author | casties |
---|---|
date | Fri, 10 Sep 2010 09:27:32 +0200 |
parents | ed8db63fab4f |
children | 2f4c427dec44 |
comparison
equal
deleted
inserted
replaced
52:435d6664ed90 | 53:f5bfcfa97e7e |
---|---|
154 def executeSQL(self, query, args=None, hasResult=True, autocommit=True): | 154 def executeSQL(self, query, args=None, hasResult=True, autocommit=True): |
155 """execute query with args on database and return all results. | 155 """execute query with args on database and return all results. |
156 result format: {"fields":fields, "rows":data}""" | 156 result format: {"fields":fields, "rows":data}""" |
157 logging.debug("executeSQL query=%s args=%s"%(query,args)) | 157 logging.debug("executeSQL query=%s args=%s"%(query,args)) |
158 cur = self.getCursor(autocommit=autocommit) | 158 cur = self.getCursor(autocommit=autocommit) |
159 if args is not None: | |
160 # make sure args is a list | |
161 if isinstance(args,basestring): | |
162 args = (args,) | |
163 | |
159 cur.execute(query, args) | 164 cur.execute(query, args) |
160 # description of returned fields | 165 # description of returned fields |
161 fields = cur.description | 166 fields = cur.description |
162 if hasResult: | 167 if hasResult: |
163 # get all data in an array | 168 # get all data in an array |