Obtaining a snapshot

Before you can write and run queries to analyze a project, you need a snapshot of that project. Each snapshot contains a database for a single language and a copy of the code to show your query results on. If a project uses multiple languages, then you can have a snapshot for each language.

There are a few ways to obtain a snapshot to use in CodeQL for Eclipse.


As of November 2019, "snapshots" have been renamed "CodeQL databases." The QL command-line tools (odasa) that were previously used to create snapshots have been superseded by a more streamlined tool—the CodeQL CLI. CodeQL databases created with this new CLI are not directly compatible with CodeQL for Eclipse, but you can run an additional command to convert them into the appropriate form. For more information, see the Database compatibility notes in the CodeQL help. You can still download and use CodeQL databases from LGTM as normal.

Downloading a CodeQL database from LGTM

You can download CodeQL databases to analyze in the licensed version of CodeQL for Eclipse from any project that is visible to you in LGTM Enterprise using the Integrations tab on the project page. The CodeQL databases for local analysis section contains the available databases for each language that has been detected. For more information, see Downloading CodeQL databases to run queries on in the help for LGTM Enterprise.

You may also analyze databases downloaded from LGTM.com, if they are compatible with your version of the plugin. However, since the analysis used on LGTM.com is updated regularly, you may find that some databases cannot be analyzed, even with the most recent version of the plugin. If this is the case, and you want to analyze databases available on LGTM.com, then you can query them directly in the query console on LGTM.com. Alternatively, you could install the open source CodeQL extension for Visual Studio Code and use this to run queries.

Once you have a database, see Importing a snapshot to find out how to use it in CodeQL for Eclipse.

Creating a database using the CodeQL CLI

You can create and bundle a CodeQL database locally using the new CodeQL CLI. For more information, see Notes for legacy QL CLI users in the CodeQL help.

Exporting a snapshot using the QL command-line tools

You can also create a snapshot locally using the QL command-line tools. You can convert this snapshot into the correct format for CodeQL for Eclipse using the export command. For more information, see Exporting data for QL plugins and extensions and LGTM in the QL command-line tools help.

What next?

Once you have obtained and imported a snapshot, you are ready to start running queries.

To find out more about snapshots, and how they are created, see What is a snapshot?

Related Topics Link IconRelated Topics