def get_method(cmd): """get method object from cmd""" if '.' in cmd: method = webnotes.get_method(cmd) else: method = globals()[cmd] webnotes.log("method:" + cmd) return method
def sql(self, query, values=(), as_dict = 0, as_list = 0, formatted = 0, debug=0, ignore_ddl=0, as_utf8=0, auto_commit=0, update=None): """ * Execute a `query`, with given `values` * returns as a dictionary if as_dict = 1 * returns as a list of lists (with cleaned up dates) if as_list = 1 """ # in transaction validations self.check_transaction_status(query) # autocommit if auto_commit: self.commit() #webnotes.errprint(query) #webnotes.errprint(values) # execute try: if values!=(): if isinstance(values, dict): values = dict(values) if debug: try: self.explain_query(query, values) webnotes.errprint(query % values) except TypeError: webnotes.errprint([query, values]) if (conf.get("logging") or False)==2: webnotes.log("<<<< query") webnotes.log(query) webnotes.log("with values:") webnotes.log(values) webnotes.log(">>>>") self._cursor.execute(query, values) else: if debug: self.explain_query(query) webnotes.errprint(query) if (conf.get("logging") or False)==2: webnotes.log("<<<< query") webnotes.log(query) webnotes.log(">>>>") self._cursor.execute(query) except Exception, e: # ignore data definition errors if ignore_ddl and e.args[0] in (1146,1054,1091): pass else: raise
def sql(self, query, values=(), as_dict = 0, as_list = 0, formatted = 0, debug=0, ignore_ddl=0, as_utf8=0, auto_commit=0, update=None): """ * Execute a `query`, with given `values` * returns as a dictionary if as_dict = 1 * returns as a list of lists (with cleaned up dates) if as_list = 1 """ # in transaction validations self.check_transaction_status(query) # autocommit if auto_commit: self.commit() # execute try: if values!=(): if isinstance(values, dict): values = dict(values) if debug: try: self.explain_query(query, values) webnotes.errprint(query % values) except TypeError: webnotes.errprint([query, values]) if getattr(conf, "logging", False)==2: webnotes.log("<<<< query") webnotes.log(query) webnotes.log("with values:") webnotes.log(values) webnotes.log(">>>>") self._cursor.execute(query, values) else: if debug: self.explain_query(query) webnotes.errprint(query) if getattr(conf, "logging", False)==2: webnotes.log("<<<< query") webnotes.log(query) webnotes.log(">>>>") self._cursor.execute(query) except Exception, e: # ignore data definition errors if ignore_ddl and e.args[0] in (1146,1054,1091): pass else: raise e