Executes the given SQL query against the connected Database.
        Parameters can, optionally, be provided. Returns a RecordCollection,
        which can be iterated over to get result rows as dictionaries.
492821
def query(self, query, fetchall=False, **params):
        

        # Execute the given query.
        cursor = self._conn.execute(text(query), **params) # TODO: PARAMS GO HERE

        # Row-by-row Record generator.
        row_gen = (Record(cursor.keys(), row) for row in cursor)

        # Convert psycopg2 results to RecordCollection.
        results = RecordCollection(row_gen)

        # Fetch all results if desired.
        if fetchall:
            results.all()

        return results
972407
def execute_sql(self, *args, **kwargs):
        
        assert self._allow_sync, (
            "Error, sync query is not allowed! Call the `.set_allow_sync()` "
            "or use the `.allow_sync()` context manager.")
        if self._allow_sync in (logging.ERROR, logging.WARNING):
            logging.log(self._allow_sync,
                        "Error, sync query is not allowed: %s %s" %
                        (str(args), str(kwargs)))
        return super().execute_sql(*args, **kwargs)
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
612871
def query(self, sql: str, args: tuple = None):
        """"""

        with self._cursor() as cursor:
            log.debug('Running SQL: ' + str((sql, args)))
            cursor.execute(sql, args)
            return cursor.fetchall()
968144
def query(self, sql, *args, **kwargs):
        
        with self.locked() as conn:
            for row in conn.query(sql, *args, **kwargs):
                yield row
812548
ResultSet executeQueryInternal(
      String sql,
      Map<String, ParameterBindingDTO> parameterBindings)
  throws SQLException
  {
    SFBaseResultSet sfResultSet;
    try
    {
      sfResultSet = sfStatement.execute(sql, parameterBindings,
                                        SFStatement.CallingMethod.EXECUTE_QUERY);
      sfResultSet.setSession(this.connection.getSfSession());
    }
    catch (SFException ex)
    {
      throw new SnowflakeSQLException(ex.getCause(),
                                      ex.getSqlState(), ex.getVendorCode(), ex.getParams());
    }

    if (resultSet != null)
    {
      openResultSets.add(resultSet);
    }
    resultSet = new SnowflakeResultSetV1(sfResultSet, this);

    return getResultSet();
  }
398029
def sql(self, sql, params=()):
        ''' 
        '''
        def _items(items):
            for item in items:
                yield self._item_class(item)

        sql = sql.strip()
        try:
            self._cursor.execute(sql, params)
        except sqlite3.OperationalError, err:
            raise SQLError('%s, SQL: %s, params: %s' % (err, sql, params) )
        except sqlite3.IntegrityError:
            raise DuplicateItem('Duplicate item, %s' % item)

        if sql.upper().startswith('SELECT'):
            return _items(self._cursor.fetchall())
        else:
            return None
1157474
def fetch_all(self, sql, *args, **kwargs):
        
        with self.locked() as conn:
            return conn.query(sql, *args, **kwargs).fetch_all()
819284
async def _run_sql(database, operation, *args, **kwargs):
    
    __log__.debug((operation, args, kwargs))

    with peewee.__exception_wrapper__:
        cursor = await database.cursor_async()

        try:
            await cursor.execute(operation, *args, **kwargs)
        except:
            await cursor.release()
            raise

        return cursor
946613
def _execute_sql_query(
            self):
        
        self.log.info('starting the ``_execute_sql_query`` method')

        # generate the api call url
        params = urllib.urlencode({'cmd': self.sqlQuery, 'format': "json"})
        # grab the results
        results = urllib.urlopen(self.sdssUrl + '?%s' % params)

        # report any errors
        ofp = sys.stdout
        results = results.read()
        if results.startswith("ERROR"):  # SQL Statement Error -> stderr
            ofp = sys.stderr
            ofp.write(string.rstrip(line) + os.linesep)

        # clean up the json response so it can be parsed
        results = results.replace(
            ": ,", ': "NULL",')
        regex = re.compile(r'"photoz_err"\:\s*(\n\s*})')
        newString = regex.sub('"photoz_err": "NULL"\g<1>', results)
        results = newString

        # parse the json results
        results = json.loads(results)[0]
        self.results = results["Rows"]

        self.log.info('completed the ``_execute_sql_query`` method')
        return
810767
def run_query_series(queries, conn):
    
    results = []
    for item in queries:
        qry = item
        kwargs = {}
        if isinstance(item, tuple):
            qry = item[0]
            kwargs = item[1]
        result = conn.update_query(qry, **kwargs)
        # pdb.set_trace()
        results.append(result)
    return results
1206386
def execute_sql(self, query):
        
        c = self.con.cursor()
        c.execute(query)
        result = []
        if c.rowcount > 0:
            try:
                result = c.fetchall()
            except psycopg2.ProgrammingError:
                pass
        return result
351211
public <T> List<T> query(String sql, RowMapper<T> rowMapper) throws SQLException{
		if (logger.isDebugEnabled()) {
			logger.debug("Executing SQL statement [" + sql + "]");
		}
		
		Connection connection = null;
		Statement stm = null;
		ResultSet rs = null;
		
		ArrayList<T> result = new ArrayList<T>();
		
		try{
			connection = ds.getConnection();
			stm = connection.createStatement();			
			rs = stm.executeQuery(sql);
			
			while(rs.next()){
				result.add( rowMapper.map(rs) );
			}
			
		} catch (SQLException e) {
			throw e;
		}finally{
			if(rs!=null) rs.close();
			if(stm!=null) stm.close();
			if(connection!=null) connection.close();			
		}
		
		return result;
	}
481509
def query(self, query, stacked=False):
        
        from jx_base.query import QueryOp

        query = QueryOp.wrap(query)

        sql, post = self._subquery(query, isolate=False, stacked=stacked)
        query.data = post(sql)
        return query.data
90320
def _execute_sql(sql, is_batch, args)
    result = []
    if sql
      #puts "RhomDbAdapter: Executing query - #{sql}; #{args}"
      begin
        result = @database.execute( sql, is_batch, args )
        #puts "result : #{result}"
      rescue Exception => e
        puts "exception when running query: #{e}"
        puts "query: #{sql}"
        raise
      end
    end
    result
  end
1174544
def queryMulti(self, queries):
		
		self.lastError = None
		self.affectedRows = 0
		self.rowcount = None
		self.record = None
		cursor = None
		
		try:
			try:
				self._GetConnection()
				#Execute query and store results
				cursor = self.conn.getCursor()
				for query in queries:
					self.conn.query = query
					if query.__class__ == [].__class__:
						self.affectedRows += cursor.execute(query[0], query[1])
					else:
						self.affectedRows += cursor.execute(query)
				self.conn.updateCheckTime()
			except Exception, e:
				self.lastError = e
		finally:
			if cursor is not None:
				cursor.close()
			self._ReturnConnection()
			if self.lastError is not None:
				raise self.lastError
			else:
				return self.affectedRows
1253040
def execute(self, query, vars=None, result=False):
        
        with self.connection() as cur:
            if self.debug:
                print(cur.mogrify(query, vars))

            resp = cur.execute(query, vars)

            if result == False:
                return resp

            else:
                columns = [i[0] for i in cur.description]
                results = cur.fetchall()
                return QueryResult(columns, results)