Using Liquibase with SQLite

SQlite is a relational database management system that implements a small, fast, and self-contained embedded SQL database engine.

Supported Versions

  • 3.X


Before using Liquibase and SQLite, ensure you have completed the following:

Driver Information

To use Liquibase and SQLite, you must install the JDBC driver. Liquibase comes with a pre-installed driver for SQLite in the liquibase/lib directory. However, you can also install this driver from GitHub or Maven’s central repository. For more information, see Adding and Updating Liquibase Drivers.

Note: If you put the sqlite-jdbc-<version>.jar file in any other directory, specify the path to it in the file: classpath: ../path_to_drivers/sqlite-jdbc-<version>.jar.

If you use Maven, add the following XML fragments to your Maven pom.xml file:


Maven will use this information to download the SQLite JDBC library from Maven’s central repository into your local repository.

Testing Your Connection

For Liquibase and SQLite to work, you need to:

  1. Ensure your SQLite database is configured. You can use sqlite3 commands like .databases and .show to check the status of the database.
  2. Specify the database URL in your file:
  3. url: jdbc:sqlite:example.db
  4. Create a Working with Changelogs file called dbchangelog (.xml, .sql, .json, or .yaml) in your project directory and add a Changelog Formats to it.
  1. Specify your changelog in the file. It should look like this:
  2. changeLogFile: dbchangelog.xml
    url: jdbc:sqlite:example.db
    driver: org.sqlite.JDBC

    Note: By default, SQLite databases do not require authentication, so the username and password attributes do not have to be specified. For more information, see SQLite User Authentication.

  3. Run the status command to see whether the connection is successful. This will create a database called example.db in your project folder if it does not already exist.
  4. liquibase --changeLogFile=dbchangelog.xml status

    Note: If you did not specify any properties in your file, they must be passed into the command line as attributes.

  5. You can preview any database changes you want to make using the updateSQL command, which will compare your changelog to your database and display the SQL needed to add your undeployed changesets. Then run your first database update with the update command.
  6. liquibase --changeLogFile=dbchangelog.xml updateSQL
    liquibase --changeLogFile=dbchangelog.xml update

After your first update, your database will contain the table you added along with the DATABASECHANGELOG and DATABASECHANGELOGLOCK tables:

  • DATABASECHANGELOG table. This table keeps a record of all the changesets that were deployed. When you deploy, the changesets in the changelog are compared with the DATABASECHANGELOG tracking table, and only the new changesets that were not found in the DATABASECHANGELOG will be deployed.
  • DATABASECHANGELOGLOCK table. This table is used internally by Liquibase to manage access to the DATABASECHANGELOG table during deployment and ensure only one instance of Liquibase is updating the database at a time, whether that is creating, updating, or deleting changes.

Related Links