Requests data from database
427699
def get(self, url: str) -> List[dict]:
        
        response = requests.get(
            url,
            headers = {'Content-type': 'application/json'},
            auth = ('scicrunch', 'perl22(query)') # for test2.scicrunch.org
        )
        output = self.process_response(response)
        return output
190645
def db(self, request):
        ''''''
        with self.mapper.begin() as session:
            world = session.query(World).get(randint(1, 10000))
        return Json(self.get_json(world)).http_response(request)
1050769
def request(self, id, **kwargs):
        
        data = self.get('requests', id, **kwargs)
        return data
1241431
def _request(self, function, params, method='POST', headers={}):
        """"""
        
        if method is 'POST':
            params = urllib.parse.urlencode(params)
            headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" }
        
        path = '/%s/%s' % (self._version, function)
        
        self._conn.request(method, path, params, headers)
        return self._conn.getresponse()
724634
def request(order_Id,amount,billing_cust_name,billing_cust_address,billing_cust_city,billing_zip_code,billing_cust_state,billing_cust_country,billing_cust_email,billing_cust_tel,billing_cust_notes="",delivery_cust_name="",delivery_cust_address="",delivery_cust_city="",delivery_zip_code="",delivery_cust_state="",delivery_cust_country="",delivery_cust_email="",delivery_cust_tel="",delivery_cust_notes="")
  		checksum = getChecksum(order_Id,amount)
  		raw_request = "Merchant_Id=#{@merchant_Id}&Amount=#{amount}&Order_Id=#{order_Id}&Redirect_Url=#{@redirect_Url}&billing_cust_name=#{billing_cust_name}&billing_cust_address=#{billing_cust_address}&billing_cust_country=#{billing_cust_country}&billing_cust_state=#{billing_cust_state}&billing_cust_city=#{billing_cust_city}&billing_zip_code=#{billing_zip_code}&billing_cust_tel=#{billing_cust_tel}&billing_cust_email=#{billing_cust_email}&billing_cust_notes=#{billing_cust_notes}&delivery_cust_name=#{delivery_cust_name}&delivery_cust_address=#{delivery_cust_address}&delivery_cust_country=#{delivery_cust_country}&delivery_cust_state=#{delivery_cust_state}&delivery_cust_city=#{delivery_cust_city}&delivery_zip_code=#{delivery_zip_code}&delivery_cust_tel=#{delivery_cust_tel}&billing_cust_notes=#{delivery_cust_notes}&Checksum=#{checksum.to_s}"
  		return encrypt_data(raw_request,@working_Key,"AES-128-CBC")[0]
  	end
1055420
def request(self, method, resource, params=None):
        

        url = self.get_url(resource, params)

        # headers

        headers = {
            'Content-Type': 'application/json'
        }

        auth = requests.auth.HTTPBasicAuth(self.username, self.password)

        # request

        log.info('Request to %s. Data: %s' % (url, params))

        response = requests.request(method, url, data=json.dumps(params), headers=headers, auth=auth)
        response.raise_for_status()

        # response

        log.info('Response from %s: %s' % (url, response.text))
        content = response.json()

        self.parse_status(content.get('status'))

        return content
308291
function requestWrite (database) {
  var deferred = q.defer();

  // Is the database currently being written?
  if(writing[database]) {
    deferred.reject('Database is being written');
    return deferred.promise();
  }

  writing[database] = true;

  // Write the database
  write(database).then(function () {
    deferred.resolve();
  }, function (err) {
    deferred.reject(err);
  });

  var time = globalConfig.db.fileTimeout;

  if(time <= 0) {
    // If there's no time limit for writing, then clear out block
    delete writing[database];
  } else {
    // If there's a time limit, wait for time to pass and remove block
    setTimeout(function () {
      delete writing[database];
    }, time);
  }

  return deferred.promise;
}
1013323
function execute(req, res) {
  var value = req.db.getKey(req.args[0], req);
  if(value === undefined) return res.send(null, null);
  var buf = dump(
    {value: value}, value.rtype || Constants.TYPE_NAMES.STRING, null);
  res.send(null, buf);
}
670573
def post(self):
        '''
        '''
        ## format sql

        data = request.get_json()
        options, sql_raw = data.get('options'), data.get('sql_raw')

        if options == 'format':
            sql_formmated = sqlparse.format(sql_raw, keyword_case='upper', reindent=True)
            return build_response(dict(data=sql_formmated, code=200))

        elif options in ('all', 'selected'):
            conn = SQL(config.sql_host, config.sql_port, config.sql_user,
                       config.sql_pwd, config.sql_db)

            result = conn.run(sql_raw)
            return build_response(dict(data=result, code=200))
        else:

            pass







        pass
503722
def requests_request(method, url, **kwargs):
    """"""
    session = local_sessions.session
    response = session.request(method=method, url=url, **kwargs)
    session.close()
    return response
839399
async def request(self, method, path, json=None):
        """"""
        url = 'https://{}:{}/api/'.format(self.host, self.port)
        url += path.format(site=self.site)

        try:
            async with self.session.request(method, url, json=json) as res:
                if res.content_type != 'application/json':
                    raise ResponseError(
                        'Invalid content type: {}'.format(res.content_type))
                response = await res.json()
                _raise_on_error(response)
                return response['data']

        except client_exceptions.ClientError as err:
            raise RequestError(
                'Error requesting data from {}: {}'.format(self.host, err)
            ) from None
490800
def request(self, method, url, parameters=dict()):
        """"""

        # The requests library uses urllib, which serializes to "True"/"False" while Pingdom requires lowercase
        parameters = self._serializeBooleans(parameters)

        headers = {'App-Key': self.apikey}
        if self.accountemail:
            headers.update({'Account-Email': self.accountemail})

        # Method selection handling
        if method.upper() == 'GET':
            response = requests.get(self.url + url, params=parameters,
                                    auth=(self.username, self.password),
                                    headers=headers)
        elif method.upper() == 'POST':
            response = requests.post(self.url + url, data=parameters,
                                     auth=(self.username, self.password),
                                     headers=headers)
        elif method.upper() == 'PUT':
            response = requests.put(self.url + url, data=parameters,
                                    auth=(self.username, self.password),
                                    headers=headers)
        elif method.upper() == 'DELETE':
            response = requests.delete(self.url + url, params=parameters,
                                       auth=(self.username, self.password),
                                       headers=headers)
        else:
            raise Exception("Invalid method in pingdom request")

        # Store pingdom api limits
        self.shortlimit = response.headers.get(
            'Req-Limit-Short',
            self.shortlimit)
        self.longlimit = response.headers.get(
            'Req-Limit-Long',
            self.longlimit)

        # Verify OK response
        if response.status_code != 200:
            sys.stderr.write('ERROR from %s: %d' % (response.url,
                                                    response.status_code))
            sys.stderr.write('Returned data: %s\n' % response.json())
            response.raise_for_status()

        return response
1261016
def post(self):
        

        resource_data = self.request.json

        record = {'id': str(len(resource_db) + 1),
                  'name': resource_data.get('name')}

        resource_db.append(record)

        return self.response_factory.ok(data=record)
707182
def get(url):
    """"""
    writeln("Getting data from url", url)
    response = requests.get(url)
    if response.status_code == 200:
        writeln(response.text)
    else:
        writeln(str(response.status_code), response.reason)
554812
private void requestPlayerDBServerPort(DeviceAnnouncement announcement) {
        Socket socket = null;
        try {
            InetSocketAddress address = new InetSocketAddress(announcement.getAddress(), DB_SERVER_QUERY_PORT);
            socket = new Socket();
            socket.connect(address, socketTimeout.get());
            InputStream is = socket.getInputStream();
            OutputStream os = socket.getOutputStream();
            socket.setSoTimeout(socketTimeout.get());
            os.write(DB_SERVER_QUERY_PACKET);
            byte[] response = readResponseWithExpectedSize(is, 2, "database server port query packet");
            if (response.length == 2) {
                setPlayerDBServerPort(announcement.getNumber(), (int)Util.bytesToNumber(response, 0, 2));
            }
        } catch (java.net.ConnectException ce) {
            logger.info("Player " + announcement.getNumber() +
                    " doesn't answer rekordbox port queries, connection refused. Won't attempt to request metadata.");
        } catch (Exception e) {
            logger.warn("Problem requesting database server port number", e);
        } finally {
            if (socket != null) {
                try {
                    socket.close();
                } catch (IOException e) {
                    logger.warn("Problem closing database server port request socket", e);
                }
            }
        }
    }
906079
def fetch_data(self, **var):
        """"""
        varstr = ','.join(name + self._convert_indices(ind)
                          for name, ind in var.items())
        query = self.query().add_query_parameter(req='data', var=varstr)
        return self._fetch(query)
1168836
function(req, res) {
            var updateJson = {};
            var updateSelector = {};

            //Request database structure
            lastQry = connection.query('SHOW COLUMNS FROM ??', req.params.table , function (err, columns) {
                if (err) return sendError(res,err.code);

                //Check if the request is provided an select value
                if (typeof req.params.id === "undefined") {
                    return sendError(res,'Please specify an selector value for the fields ');
                } else {
                    updateSelector.value = req.params.id;
                    updateSelector.field = findPrim(columns,req.query[settings.paramPrefix + 'field']);
                }

                //If the user only wants to update files
                if( Object.keys(req.body).length == 0) {
                    req.body = req.files;
                }
                var value;
                var iterator = function (i) {
                    if (i >= columns.length || (typeof req.body.length === "undefined" && typeof req.files.length !== "undefined")) {
                        if(JSON.stringify(updateJson) !== '{}') {
                            updateIntoDB();
                        } else {
                            return sendError(res,'No Data received!');
                        }
                        return;
                    }
                    var dbField = columns[i];
                    var field = dbField.Field;
                    //Check if the current checked field is set
                    if(typeof req.body[field] !== "undefined" || (dbField.Default == 'FILE' && typeof req.files[field] !== "undefined") ) {
                        //First check if the field is required
                        if(dbField.Null == 'NO' && dbField.Extra != 'auto_increment') {
                            value = checkIfSentvaluesAreSufficient(req,dbField);
                            if(value !== false) {
                                updateJson[field] = value;
                                iterator(i + 1);
                            } else {
                                return sendError(res,"Not all 'NOT NULL' fields are filled ("+ field +" is missing)");
                            }
                        }  else {
                            //Check for not required fields
                            //Skip auto_incremented fields
                            if(dbField.Extra === 'auto_increment') {
                                iterator(i + 1);
                            } else {
                                //Check if the field was provided by the client
                                var defined = false;
                                if(dbField.Default == "FILE") {
                                    if(req.files.hasOwnProperty(dbField.Field)) {
                                        defined = true;
                                    }
                                } else {
                                    if(typeof req.body[field] !== "undefined") {
                                        defined = true;
                                    }
                                }

                                //If it was provided, check if the values are okay
                                if(defined) {
                                    value = checkIfSentvaluesAreSufficient(req,dbField);
                                    if(value !== false) {
                                        updateJson[field] = value;
                                        iterator(i + 1);
                                    } else {
                                        if(dbField.Default == "FILE") {
                                            return sendError(res, 'Value for field ' + field + ' is not sufficient. Either the file is to large or an other error occured');
                                        } else {
                                            return sendError(res, 'Value for field ' + field + ' is not sufficient. Expecting ' + dbField.Type + ' but got ' + typeof req.body[field]);
                                        }
                                    }
                                } else {
                                    //If not, don't mind
                                    iterator(i + 1);
                                }
                            }
                        }
                    } else {
                        iterator(i + 1);
                    }
                };

                iterator(0); //start the async "for" loop

                function updateIntoDB() {
                    //Yaaay, alle Tests bestanden gogo, insert!
                    lastQry = connection.query('UPDATE ?? SET ? WHERE ?? = ?', [req.params.table , updateJson, updateSelector.field, updateSelector.value] , function (err) {
                        if (err) return sendError(res,err.code);
                        sendSuccessAnswer(req.params.table , res, req.params.id, updateSelector.field);

                    });
                }
            });
        }