Database Synchronization
Learn how to synchronize database schema information with the Oxy sync command
Oxy sync
The oxy sync
command collects semantic information from your databases and stores it in your local repository for use by agents and other Oxy features. This semantic information includes table structures, relationships, and sample data that help agents understand your data model.
Command Overview
Arguments
DATABASE_NAME
(optional): The name of a specific database to sync, as defined in yourconfig.yml
file. If omitted, all databases will be synced.
Options
-d, --datasets <DATASETS>
: Specify one or more datasets to sync within the database. Can be used multiple times.-o, --overwrite
: Overwrite existing files during synchronization. By default, existing files are skipped.
Usage Examples
Sync All Databases
This command will synchronize all databases defined in your config.yml
file. By default, it will skip any files that already exist.
Sync a Specific Database
This syncs only the database named “my_database” from your configuration.
Sync Specific Datasets
This will sync only the “customers” and “orders” datasets from the “my_database” database.
Overwrite Existing Files
By using the -o
flag, existing semantic files will be overwritten during synchronization.
Output and Warnings
The sync
command provides feedback about the synchronization process:
-
Skipped Files: When a file already exists and overwrite mode is off (default), the command will display a warning indicating which files were skipped.
-
Overwritten Files: When the
-o
flag is used, the command will display a warning showing which existing files were overwritten.
Understanding the Synced Data
When you run the oxy sync
command, Oxy will:
- Connect to each configured database
- Extract schema information, including tables, columns, relationships, and data types
- Generate semantic models representing this data
- Save these models as files in your project directory
These semantic files are then used by agents when you ask questions about your data, enabling them to generate accurate SQL queries and understand your data structure.
Configuration
Before using the sync
command, ensure your databases are properly configured in your config.yml
file. For example:
See the configuration documentation for more details on setting up your database connections.