Project

General

Profile

« Previous | Next » 

Revision 2212

sql.py: DbConn: Added esc_value()

View differences:

lib/sql.py
249 249
                try: return self.iter.next()
250 250
                except StopIteration: return None
251 251
    
252
    def esc_value(self, value):
253
        module = util.root_module(db.db)
254
        if module == 'psycopg2': return db.db.cursor().mogrify('%s', [value])
255
        elif module == 'MySQLdb':
256
            import _mysql
257
            return _mysql.escape_string(value)
258
        else: raise NotImplementedError("Can't escape value for "+module
259
            +' database')
260
    
252 261
    def run_query(self, query, params=None, cacheable=False):
253 262
        '''Translates known DB errors to typed exceptions:
254 263
        See self.DbCursor.execute().'''

Also available in: Unified diff