Query the database file.
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
124891
def query(self):
        """"""

        return self._session.query(Process).filter(Process.d_vid == self._d_vid)
1041833
def search(cls, query, page=1):
        
        path = '/files/search/{query}/page/{page}'.format(query=query, page=page)
        result = cls.client.request(path)
        files = result['files']
        return [cls(f) for f in files]
353759
def db(ctx):
    """"""

    from hfos import database
    database.initialize(ctx.obj['dbhost'], ctx.obj['dbname'])
    ctx.obj['db'] = database
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
569802
def QueryDatabases(self, query, options=None):
        
        if options is None:
            options = {}

        def fetch_fn(options):
            return self.__QueryFeed('/dbs',
                                    'dbs',
                                    '',
                                    lambda r: r['Databases'],
                                    lambda _, b: b,
                                    query,
                                    options), self.last_response_headers
        return query_iterable.QueryIterable(self, query, options, fetch_fn)
668475
def select(cls, *args, **kwargs):
        """"""
        query = super(Model, cls).select(*args, **kwargs)
        query.database = cls._get_read_database()
        return query
651130
def init_db():
    
    with current_app.app_context():
        for filename in CHILL_CREATE_TABLE_FILES:
            db.execute(text(fetch_query_string(filename)))
635932
def db(self, connection_string=None):
        """"""

        connection_string = connection_string or self.settings["db"]

        if not hasattr(self, "_db_conns"):
            self._db_conns = {}
        if not connection_string in self._db_conns:
            self._db_conns[connection_string] = oz.sqlalchemy.session(connection_string=connection_string)

        return self._db_conns[connection_string]
310798
def _query_db(self, mapping):
        
        model = self.models[mapping.get("table")]

        # Use primary key instead of the field mapped to SF Id
        fields = mapping.get("fields", {}).copy()
        if mapping["oid_as_pk"]:
            del fields["Id"]
        id_column = model.__table__.primary_key.columns.keys()[0]
        columns = [getattr(model, id_column)]

        for f in fields.values():
            columns.append(model.__table__.columns[f])
        lookups = mapping.get("lookups", {}).copy()
        for lookup in lookups.values():
            lookup["aliased_table"] = aliased(
                self.metadata.tables["{}_sf_ids".format(lookup["table"])]
            )
            columns.append(lookup["aliased_table"].columns.sf_id)

        query = self.session.query(*columns)
        if "record_type" in mapping and hasattr(model, "record_type"):
            query = query.filter(model.record_type == mapping["record_type"])
        if "filters" in mapping:
            filter_args = []
            for f in mapping["filters"]:
                filter_args.append(text(f))
            query = query.filter(*filter_args)
        for sf_field, lookup in lookups.items():
            # Outer join with lookup ids table:
            # returns main obj even if lookup is null
            key_field = get_lookup_key_field(lookup, sf_field)
            value_column = getattr(model, key_field)
            query = query.outerjoin(
                lookup["aliased_table"],
                lookup["aliased_table"].columns.id == value_column,
            )
            # Order by foreign key to minimize lock contention
            # by trying to keep lookup targets in the same batch
            lookup_column = getattr(model, key_field)
            query = query.order_by(lookup_column)
        self.logger.info(str(query))
        return query
487814
def bulk_query_file(self, path, *multiparams):
        

         # If path doesn't exists
        if not os.path.exists(path):
            raise IOError("File '{}'' not found!".format(path))

        # If it's a directory
        if os.path.isdir(path):
            raise IOError("'{}' is a directory!".format(path))

        # Read the given .sql file into memory.
        with open(path) as f:
            query = f.read()

        self._conn.execute(text(query), *multiparams)
1025376
def read
      bookmark_file = Dir.glob(File.expand_path(path)).shift
      raise "Did not find file #{path}" unless bookmark_file

      db = SQLite3::Database.new(path)

      import = db.execute(QUERY_STRING)
    end
830428
def run_query(db, query):
    '''
    
    '''
    if db in [x.keys()[0] for x in show_dbs()]:
        conn = _connect(show_dbs(db)[db]['uri'])
    else:
        log.debug('No uri found in pillars - will try to use oratab')
        # if db does not have uri defined in pillars
        # or it's not defined in pillars at all parse oratab file
        conn = _connect(uri=db)
    return conn.cursor().execute(query).fetchall()
589868
def get_list_database(self):
        """"""
        url = "db"

        response = self.request(
            url=url,
            method='GET',
            expected_response_code=200
        )

        return response.json()
1119387
def query(query, params={}, epoch=None,
          expected_response_code=200, database=None):
    """"""
    db = get_db()
    database = database or settings.INFLUXDB_DATABASE
    return db.query(query, params, epoch, expected_response_code, database=database)
675791
def query_file(self, file_sha, verbose=False):
        

        # Sanity check sha hash input
        if len(file_sha) not in [64, 40]:  # sha256 and sha1 lengths
            print('File sha looks malformed: {:s}'.format(file_sha))
            return {'file_sha': file_sha, 'malformed': True}

        # Call and return the internal query method
        return self._query('file', file_sha, verbose)
920871
def get_dataset(self, key, info):
        """"""
        logger.debug("Reading %s.", key)
        return self.file_content[key.name]