Skip to content

Database Queries

Robert J. Gifford edited this page Sep 23, 2024 · 7 revisions

Querying the Database and Exporting Results

This guide explains how to execute database queries in GLUE and export the results. We'll cover how to use the list command for core and custom tables, specify conditions with the where clause, and configure console output settings for exporting data.

1. Listing Data Using the list Command

The list command retrieves data from GLUE's core tables or custom tables defined within a project. The basic structure is as follows

list <tableName> <field1> <field2> ... [options]

Example

In the Dengue-GLUE project, the following command lists the sequence ID, source name, and genotype of sequences from a specific source:

list sequence sequenceID source.name genotype -w "source.name = 'ncbi-nuccore-short'"

Options for the list Command:

  • -w "<whereClause>" : Applies filters (explained below).
  • -p <pageSize> : Defines how many results to display per page.
  • -l <fetchLimit> : Limits the total number of records fetched.
  • -o <fetchOffset> : Skips a number of records.
  • -s <sortProperties> : Sorts results by the specified field(s).

Using the where Clause

The where clause specifies conditions to filter results. It must be enclosed in double quotes (" "). If filtering by a text field (e.g., varchar type), values must be enclosed in single quotes (' '), within the double-quoted clause.

Example:

To list sequences from the ncbi-nuccore-short source: