Calls a MySQL stored procedure procname and returns the return values. This uses DictCursor.
            To get return values back out of a stored procedure, prefix the parameter with a @ character.
357587
def callproc(self, procname, parameters=(), quiet=False, expect_return_value=False):
        
        self.procedures_run += 1
        i = 0
        errcode = 0
        caughte = None

        out_param_indices = []
        for j in range(len(parameters)):
            p = parameters[j]
            if type(p) == type('') and p[0] == '@':
                assert(p.find(' ') == -1)
                out_param_indices.append(j)

        if procname not in self.list_stored_procedures():
            raise Exception("The stored procedure '%s' does not exist." % procname)
        if not re.match("^\s*\w+\s*$", procname):
            raise Exception("Expected a stored procedure name in callproc but received '%s'." % procname)
        while i < self.numTries:
            i += 1
            try:
                self._get_connection()
                cursor = self.connection.cursor()
                if type(parameters) != type(()):
                    parameters = (parameters,)
                errcode = cursor.callproc(procname, parameters)
                self.lastrowid = int(cursor.lastrowid)
                cursor.close()

                # Get the out parameters
                out_param_results = []
                if out_param_indices:
                    out_param_results = self.execute('SELECT %s' % ", ".join(['@_%s_%d AS %s' % (procname, pindex, parameters[pindex][1:]) for pindex in out_param_indices]))

                return out_param_results
            except MySQLdb.OperationalError, e:
                self._close_connection()
                errcode = e[0]
                caughte = e
                continue
            except:
                self._close_connection()
                traceback.print_exc()
                break

        if not quiet:
            sys.stderr.write("\nSQL execution error call stored procedure %s at %s:" % (
            procname, datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
            sys.stderr.write("\nErrorcode/Error: %d - '%s'.\n" % (errcode, str(caughte)))
            sys.stderr.flush()
        raise MySQLdb.OperationalError(caughte)
678919
@SuppressWarnings({ "rawtypes", "unchecked" })
    private static void generateCodeForReturnStatement(Code code, Class methodReturnType,
            Local localForResultOfInvoke, Local localOfMethodReturnType, Local aBoxedResult) {
        if (PRIMITIVE_TO_UNBOX_METHOD.containsKey(methodReturnType)) {
            code.cast(aBoxedResult, localForResultOfInvoke);
            MethodId unboxingMethodFor = getUnboxMethodForPrimitive(methodReturnType);
            code.invokeVirtual(unboxingMethodFor, localOfMethodReturnType, aBoxedResult);
            code.returnValue(localOfMethodReturnType);
        } else if (void.class.equals(methodReturnType)) {
            code.returnVoid();
        } else {
            code.cast(localOfMethodReturnType, localForResultOfInvoke);
            code.returnValue(localOfMethodReturnType);
        }
    }
147821
def executeSQL(self, sql, args=()):
        
        sql = self._execSQL(sql, args)
        result = self.cursor.lastRowID()
        if self.executedThisTransaction is not None:
            self.executedThisTransaction.append((result, sql, args))
        return result
785469
public Statement getPreparedStatement(String sql,
			Object[] parameters, boolean returnValues) throws DatabaseException {
		Statement stmt = null;
		try {
			if(supportPreparedStatement()){
				if (appendReturningColumnClause() && returnValues) {
					stmt = connection.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
				} else {
					stmt = connection.prepareStatement(sql);
				}
				if (parameters != null) {
					for (int i = 0; i < parameters.length; i++) {
						((PreparedStatement)stmt).setObject(i + 1,getEquivalentDBObject(parameters[i]));
					}
				}
			}else{//no substition of parameters
				stmt = connection.createStatement();
				return stmt;
			}
		} catch (SQLException e) {
			logSQL(stmt, sql, parameters, true);
			e.printStackTrace();
			throw new DataEntryException(e.getMessage());
		}
		return stmt;
	}
563243
def callproc(self, procname, parameters=()):
        
        self._assert_open()
        return self._callproc(procname, parameters)
417657
def execQuery(self, sql, parameters = None, cursorClass = MySQLdb.cursors.Cursor, InnoDB = False):
		""""""
		i = 0
		errcode = 0
		caughte = None
		while i < self.numTries:
			i += 1
			try:	
				cursor = self.connection.cursor(cursorClass)
				if parameters:
					errcode = cursor.execute(sql, parameters)
				else:
					errcode = cursor.execute(sql)
				if InnoDB:
					self.connection.commit()
				results = cursor.fetchall()
				self.lastrowid = int(cursor.lastrowid)
				cursor.close()
				return results
			except MySQLdb.OperationalError, e:
				errcode = e[0]
				# errcodes of 2006 or 2013 usually indicate a dropped connection  
				# errcode 1100 is an error with table locking
				print(e)
				self.connection.ping(True)
				caughte = e
				continue
			except:				
				traceback.print_exc()
				break
		
		sys.stderr.write("\nSQL execution error in query at %s:" % datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
		sys.stderr.write("\n %s." % sql)
		sys.stderr.flush()
		sys.stderr.write("\nErrorcode: '%s'.\n" % (str(caughte)))
		sys.stderr.flush()
		raise MySQLdb.OperationalError(caughte)
563323
def varchar(self, field=None):
        
        assert field is not None, "The field parameter must be passed to the 'varchar' method."
        max_length = field.max_length

        def source():
            length = random.choice(range(1, max_length + 1))
            return "".join(random.choice(general_chars) for i in xrange(length))
        return self.get_allowed_value(source, field)
870641
def _make_sql_params(self,kw):
        """"""
        return ['%s=?' %k for k in kw.keys() ]
        for k,v in kw.iteritems():
            vals.append('%s=?' %k)
        return vals
1291486
def returner(ret):
    '''
    
    '''
    log.debug('sqlite3 returner <returner> called with data: %s', ret)
    conn = _get_conn(ret)
    cur = conn.cursor()
    sql = '''INSERT INTO salt_returns
             (fun, jid, id, fun_args, date, full_ret, success)
             VALUES (:fun, :jid, :id, :fun_args, :date, :full_ret, :success)'''
    cur.execute(sql,
                {'fun': ret['fun'],
                 'jid': ret['jid'],
                 'id': ret['id'],
                 'fun_args': six.text_type(ret['fun_args']) if ret.get('fun_args') else None,
                 'date': six.text_type(datetime.datetime.now()),
                 'full_ret': salt.utils.json.dumps(ret['return']),
                 'success': ret.get('success', '')})
    _close_conn(conn)
803797
def _get_cursor(self):
        '''
        
        '''
        _options = self._get_options()
        conn = sqlcipher.connect(_options.get('database'),
                                 timeout=float(_options.get('timeout')))
        conn.execute('pragma key="{0}"'.format(_options.get('pass')))
        cursor = conn.cursor()
        try:
            yield cursor
        except sqlcipher.Error as err:
            log.exception('Error in ext_pillar SQLCipher: %s', err.args)
        finally:
            conn.close()
900769
protected boolean isStoredProcedure(String sql)
    {
        /*
        Stored procedures start with
        {?= call <procedure-name>[<arg1>,<arg2>, ...]}
        or
        {call <procedure-name>[<arg1>,<arg2>, ...]}
        but also statements with white space like
        { ?= call <procedure-name>[<arg1>,<arg2>, ...]}
        are possible.
        */
        int k = 0, i = 0;
        char c;
        while(k < 3 && i < sql.length())
        {
            c = sql.charAt(i);
            if(c != ' ')
            {
                switch (k)
                {
                    case 0:
                        if(c != '{') return false;
                        break;
                    case 1:
                        if(c != '?' && c != 'c') return false;
                        break;
                    case 2:
                        if(c != '=' && c != 'a') return false;
                        break;
                }
                k++;
            }
            i++;
        }
        return true;
    }
1148404
def _get_crud_params(compiler, stmt, **kw):
        

        compiler.postfetch = []
        compiler.insert_prefetch = []
        compiler.update_prefetch = []
        compiler.returning = []

        # no parameters in the statement, no parameters in the
        # compiled params - return binds for all columns
        if compiler.column_keys is None and stmt.parameters is None:
            return [(c, crud._create_bind_param(compiler, c, None,
                                                required=True))
                    for c in stmt.table.columns]

        if stmt._has_multi_parameters:
            stmt_parameters = stmt.parameters[0]
        else:
            stmt_parameters = stmt.parameters

        # getters - these are normally just column.key,
        # but in the case of mysql multi-table update, the rules for
        # .key must conditionally take tablename into account
        if SA_VERSION >= SA_1_1:
            _column_as_key, _getattr_col_key, _col_bind_name = \
                crud._key_getters_for_crud_column(compiler, stmt)
        else:
            _column_as_key, _getattr_col_key, _col_bind_name = \
                crud._key_getters_for_crud_column(compiler)

        # if we have statement parameters - set defaults in the
        # compiled params
        if compiler.column_keys is None:
            parameters = {}
        else:
            parameters = dict((_column_as_key(key), crud.REQUIRED)
                              for key in compiler.column_keys
                              if not stmt_parameters or
                              key not in stmt_parameters)

        # create a list of column assignment clauses as tuples
        values = []

        if stmt_parameters is not None:
            crud._get_stmt_parameters_params(
                compiler,
                parameters, stmt_parameters, _column_as_key, values, kw)

        check_columns = {}

        crud._scan_cols(compiler, stmt, parameters,
                        _getattr_col_key, _column_as_key,
                        _col_bind_name, check_columns, values, kw)

        if stmt._has_multi_parameters:
            values = crud._extend_values_for_multiparams(compiler, stmt,
                                                         values, kw)

        return values
497255
def fetch_fieldnames(self, sql: str, *args) -> List[str]:
        """"""
        self.ensure_db_open()
        cursor = self.db.cursor()
        self.db_exec_with_cursor(cursor, sql, *args)
        try:
            return [i[0] for i in cursor.description]
        except:  # nopep8
            log.exception("fetch_fieldnames: SQL was: " + sql)
            raise
1123335
def _produce_return(self, cursor):
        
        self.callback(self._row_generator(cursor), *self.cb_args)
        return None
104521
def get_callproc_signature(self, name, param_types):
    
    if isinstance(param_types[0], (list, tuple)):
      params = [self.sql_writer.to_placeholder(*pt) for pt in param_types]
    else:
      params = [self.sql_writer.to_placeholder(None, pt) for pt in param_types]

    return name + self.sql_writer.to_tuple(params)
715617
def get_mysql_args(db_config):
    
    db = db_config['NAME']

    mapping = [('--user={0}', db_config.get('USER')),
               ('--password={0}', db_config.get('PASSWORD')),
               ('--host={0}', db_config.get('HOST')),
               ('--port={0}', db_config.get('PORT'))]
    args = apply_arg_values(mapping)
    args.append(db)

    return args
1142971
function(sql, val, callback) {
  let qry = (typeof sql === 'object') ? sql : mysql.format(sql, val);
  if (!callback && typeof val === 'function') callback = val; // Handle 2 parm scenario

  _pool.getConnection((err, conn) => {
    _pool.query(qry, (err, items, fields) => {
      if (err) return callback(err);

      conn.release();

      callback(err, items);
    });
  });
}