Execute a query.

    database
        Name of the database to query on.

    query
        InfluxQL query string.
321188
def query(database, query, **client_args):
    '''
    
    '''
    client = _client(**client_args)
    _result = client.query(query, database=database)

    if isinstance(_result, collections.Sequence):
        return [_pull_query_results(_query_result) for _query_result in _result if _query_result]
    return [_pull_query_results(_result) if _result else {}]
791485
def _executing(self, sql, params=[]):
        
        with self.connection() as connection:
            for row in connection.execute(sql, params):
                yield row
                if not self._db:
                    return
1051652
def call(self, routine, *args):
        

        (query, replacements) = self.__build_query(routine, args)

        return self.__execute_text(query, **replacements)
730448
def execute(self, conn,  origin_site_name="", dataset="", block_name="", transaction = False):
        
        if not conn:
            dbsExceptionHandler("dbsException-db-conn-failed",
                                "Oracle/Block/List.  Expects db connection from upper layer.", self.logger.exception)
        binds = {}
        if origin_site_name:
            wheresql = 'WHERE B.ORIGIN_SITE_NAME = :origin_site_name'
            binds.update(origin_site_name=origin_site_name)

        if dataset:
            if 'wheresql' in locals():
                wheresql += ' AND DS.DATASET = :dataset'
            else:
                wheresql = 'WHERE DS.DATASET = :dataset'
            binds.update(dataset=dataset)

        if block_name:
            if 'wheresql' in locals():
                wheresql += ' AND B.BLOCK_NAME = :block_name'
            else:
                wheresql = 'WHERE B.BLOCK_NAME = :block_name'
            binds.update(block_name=block_name)

        sql = '{sql} {wheresql}'.format(sql=self.sql, wheresql=wheresql)

        cursors = self.dbi.processData(sql, binds, conn, transaction, returnCursor=True)
        result = []
        for cursor in cursors:
            result.extend(self.formatCursor(cursor, size=100))
        return result
967206
def _execute_query(self):
        ''''''
        pipe = self.pipe
        if not self.card:
            if self.meta.ordering:
                self.ismember = getattr(self.backend.client, 'zrank')
                self.card = getattr(pipe, 'zcard')
                self._check_member = self.zism
            else:
                self.ismember = getattr(self.backend.client, 'sismember')
                self.card = getattr(pipe, 'scard')
                self._check_member = self.sism
        else:
            self.ismember = None
        self.card(self.query_key)
        result = yield pipe.execute()
        yield result[-1]
533698
def execute(self, fetchall=False, fetchone=False, use_labels=True):
        
        query = self.get_query(use_labels=use_labels)
        if fetchall:
            return flask.g.db_conn.execute(query).fetchall()
        elif fetchone:
            return flask.g.db_conn.execute(query).fetchone()
35350
private void executeSQL(String sqlName, String tableName,
			String geometryColumnName) {
		executeSQL(sqlName, tableName, geometryColumnName, null);
	}
167708
def Query(self, sql_query):
    """"""
    results = {}

    try:
      self._connection = sqlite.connect(self.name)
      self._connection.execute("PRAGMA journal_mode=%s" % self.journal_mode)
      self._cursor = self._connection.cursor()
      results = self._cursor.execute(sql_query).fetchall()

    except sqlite.Error as error_string:
      logging.warning("SQLite error %s", error_string)

    return results
870682
def query(self, query, *parameters, **kwargs):
        """"""
        cursor = self._cursor()
        try:
            self._execute(cursor, query, parameters or None, kwargs)
            if cursor.description:
                column_names = [column.name for column in cursor.description]
                res = [Row(zip(column_names, row)) for row in cursor.fetchall()]
                cursor.close()
                return res
        except:
            cursor.close()
            raise
557485
def execute(self, query, params=None, cursor=None):
        
        conn = yield self._get_conn()
        try:
            cur = conn.cursor(cursor)
            yield cur.execute(query, params)
            yield cur.close()
        except:
            self._close_conn(conn)
            raise
        else:
            self._put_conn(conn)
        raise Return(cur)
1143193
def Query(self, query):
    
    cursor = self._database.cursor()
    cursor.execute(query)
    return cursor
1012595
def execute_sql(self, statement):
        
        path = '/archive/{}/sql'.format(self._instance)
        req = archive_pb2.ExecuteSqlRequest()
        req.statement = statement

        response = self._client.post_proto(path=path,
                                           data=req.SerializeToString())
        message = archive_pb2.ExecuteSqlResponse()
        message.ParseFromString(response.content)
        if message.HasField('result'):
            return message.result
        return None
1370120
def get_db():
    """"""
    return client.InfluxDBClient(
        settings.INFLUXDB_HOST,
        settings.INFLUXDB_PORT,
        settings.INFLUXDB_USER,
        settings.INFLUXDB_PASSWORD,
        settings.INFLUXDB_DATABASE,
    )
1097966
def _query(self, sql, *args):
      
      if not self._con:
          logger.debug(("Open MBTiles file '%s'") % self.filename)
          self._con = sqlite3.connect(self.filename)
          self._cur = self._con.cursor()
      sql = ' '.join(sql.split())
      logger.debug(("Execute query '%s' %s") % (sql, args))
      try:
          self._cur.execute(sql, *args)
      except (sqlite3.OperationalError, sqlite3.DatabaseError) as e:
          raise InvalidFormatError(("%s while reading %s") % (e, self.filename))
      return self._cur
432323
function runQuery(client, queryString, args, callback) {
  if (activeBackend === 'mysql') {
    queryString = queryString.replace(/\$\d+/, '?');
  }

  client.query(queryString, args, function (err, result) {
    if (err) {
      callback(err, null);
      return;
    }
    if (activeBackend === 'mysql') {
      callback(err, result);
    }
    else if (activeBackend === 'pgsql') {
      var rows = [];
      if (result.rows) {
        rows = result.rows;
      }
      callback(err, rows);
    }
  });
}
415787
def main(host='localhost', port=8086):
    """"""
    now = datetime.datetime.today()
    points = []

    for angle in range(0, 360):
        y = 10 + math.sin(math.radians(angle)) * 10

        point = {
            "measurement": 'foobar',
            "time": int(now.strftime('%s')) + angle,
            "fields": {
                "value": y
            }
        }
        points.append(point)

    client = InfluxDBClient(host, port, USER, PASSWORD, DBNAME)

    print("Create database: " + DBNAME)
    client.create_database(DBNAME)
    client.switch_database(DBNAME)

    # Write points
    client.write_points(points)

    time.sleep(3)

    query = 'SELECT * FROM foobar'
    print("Querying data: " + query)
    result = client.query(query, database=DBNAME)
    print("Result: {0}".format(result))

    """
    You might want to comment the delete and plot the result on InfluxDB
    Interface. Connect on InfluxDB Interface at http://127.0.0.1:8083/
    Select the database tutorial -> Explore Data

    Then run the following query:

        SELECT * from foobar
    """

    print("Delete database: " + DBNAME)
    client.drop_database(DBNAME)
421112
def query(query, args_or_dbname, params = {})
      query = transmute_data(query)
      args = args_or_dbname.is_a?(String) ? [db_alias(args_or_dbname)] : args_or_dbname
      args = transmute_data(args)
      get root_url("api/query"), params.merge(:q => query, :args => args)
    end