2. Features#

2.1. Command Line Interface#

Command Line Interface
  • Showing CLI commands.

2.2. Rich Database Metadata#

Note

More information about the metadata can be found under design/metadata

Rich Metadata
  • Showing the metadata tables.
    • dvc.database_revision_history table which shows the revision SQL files applied.

    • dvc.database_version_history table which shows the database version which results from the revision SQL files applied.

2.3. Upgrade or Downgrade#

Rich Metadata
  • Showing upgrade and downgrade command.
    • Started from database version 1 (Shown via dvc db current)

    • Showed the Revision SQL files under the default folder sample_revision_sql_files.

    • Applied database upgrade via dvc db upgrade.

    • Showed the database version became 2.

    • Applied database downgrade via dvc db downgrade.

    • Showed the database version was back to 1.

2.4. Flexible Configuration Format#

Configuration is read either from i. Configuration File (config.yaml) or ii. Environment Variable

2.4.1. Configuration File#

Note

The configuration file template can be generated via dvc cfg init

Config Via Configuration File
  • Showing dvc tool reads configuration from a configuration file.
    • Ran a postgres DB via docker docker run -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -e POSTGRES_DB=test -p 5433:5432 postgres:latest

    • Copied a config.yaml file with configurations which match the spun up postgres DB.

    • Pinged the DB with dvc db ping. Success!

  • The config.yaml file looks as follows:

credentials:
    dbflavour: postgres
    dbname: 'test'
    host: 'localhost'
    password: 'test'
    port: 5433
    user: 'test'
database_revision_sql_files_folder: sample_revision_sql_files

2.4.2. Environment Variable#

Note

The names of the environment variables can be found in the docker compose file

Config Via Env Var
  • Showing dvc tool reads configuration from environment variables
    • Ran a postgres DB via docker docker run -e POSTGRES_USER=test -e POSTGRES_PASSWORD=test -e POSTGRES_DB=test -p 5433:5432 postgres:latest

    • Loaded the env variables to the shell.

    • Pinged the DB with dvc db ping. Success!

  • The environment variables look as follows:

>>> printnev| grep DVC
DVC__DATABASE_REVISION_SQL_FILES_FOLDER=sample_revision_sql_files
DVC__USER=test
DVC__PASSWORD=test
DVC__HOST=postgres_db
DVC__PORT=5432
DVC__DBNAME=test
DVC__DBFLAVOUR=postgres