@@ -171,27 +171,32 @@ def __init__(self, configfile, use_float=False, write_cfg_file=False):
171
171
raise dbErrConnect (err )
172
172
173
173
def query (self , command ):
174
- self .cursor .execute (command )
174
+ try :
175
+ self .cursor .execute (command )
175
176
176
- debug (" QUERY: command=%r" % command )
177
+ debug (" QUERY: command=%r" % command )
177
178
178
- # passing a query object to match response from pygresql
179
- return query_obj (self .cursor )
179
+ # passing a query object to match response from pygresql
180
+ return query_obj (self .cursor )
181
+ except Exception as e :
182
+ raise DatabaseError (e )
180
183
181
184
def query_float (self , command , as_dict = False ):
182
185
# deprecated: using psycopg2 now solves the problem of returning float numbers
183
186
# still in to maintain backwards compatibility
187
+ try :
188
+ if not as_dict :
189
+ cursor = self .cnn .cursor ()
190
+ cursor .execute (command )
191
+ recordset = cast_array_to_float (cursor .fetchall ())
192
+ else :
193
+ # return results as a dictionary
194
+ self .cursor .execute (command )
195
+ recordset = cast_array_to_float (self .cursor .fetchall ())
184
196
185
- if not as_dict :
186
- cursor = self .cnn .cursor ()
187
- cursor .execute (command )
188
- recordset = cast_array_to_float (cursor .fetchall ())
189
- else :
190
- # return results as a dictionary
191
- self .cursor .execute (command )
192
- recordset = cast_array_to_float (self .cursor .fetchall ())
193
-
194
- return recordset
197
+ return recordset
198
+ except Exception as e :
199
+ raise DatabaseError (e )
195
200
196
201
def get (self , table , filter_fields , return_fields = None , limit = None ):
197
202
"""
0 commit comments