Skip to main content

CLI

Ryx ships a management CLI for migrations, introspection, shell access, native database shells, destructive flushes, and version checks.

python -m ryx [global-options] <command> [command-options]
ryx [global-options] <command> [command-options]

Global options:

FlagPurpose
--url, -uDatabase URL. Overrides environment/config values
--settings, -sSettings module name. Defaults to ryx_settings
--verbose, -vEnable verbose output
--debugEnable debug mode

The command registry is plugin-aware, so additional commands can be registered by Ryx CLI plugins.

Configuration Resolutionโ€‹

The CLI resolves configuration from:

  1. Global CLI flags
  2. Environment variables
  3. A settings module
  4. Config files in the current working directory

Supported config file names:

ryx.yaml
ryx.yml
ryx.toml
ryx.json

Environment variables:

export RYX_DATABASE_URL="postgres://user:pass@localhost/app"
export RYX_DB_REPLICA_URL="postgres://user:pass@localhost/app_replica"
export RYX_DB_LOGS_URL="sqlite:///logs.db"

Example TOML:

[urls]
default = "postgres://user:pass@localhost/app"
replica = "postgres://user:pass@localhost/app_replica"

[pool]
max_conn = 10
min_conn = 1
connect_timeout = 30
idle_timeout = 600
max_lifetime = 1800

[models]
files = ["myapp.models"]

[migrations]
dir = "migrations"

makemigrationsโ€‹

Detect model changes and generate migration files.

python -m ryx makemigrations --models myapp.models
python -m ryx makemigrations --models myapp.models --name add_posts
python -m ryx makemigrations --models myapp.models --check

Options:

FlagPurpose
--models MODULEDotted module path containing models; can also come from config
--dir DIRMigrations directory. Defaults to migrations
--alias ALIASGenerate migrations in an alias-specific subdirectory
--name NAMEOverride the generated migration name slug
--checkExit with status 1 if changes are detected
--squashReserved flag for squashing multiple migrations

Use --check in CI to fail when models and migration files drift.

migrateโ€‹

Apply pending migrations.

python -m ryx --url postgres://user:pass@localhost/app migrate --models myapp.models
python -m ryx migrate --models myapp.models --dry-run
python -m ryx migrate --models myapp.models --database replica
python -m ryx migrate --models myapp.models --schema tenant_1

Options:

FlagPurpose
--dry-runPrint SQL without executing
--models MODULEDotted module path containing models
--dir DIRMigrations directory. Defaults to migrations
--planShow migration plan without executing
--database ALIASRun migrations for one database alias
--no-interactiveFail if no migration files are found; useful in CI
--schema SCHEMAPostgreSQL schema for multi-schema migrations

migrate initializes Ryx with the resolved URL mapping before running the migration runner.

showmigrationsโ€‹

List migration files and whether they are applied.

python -m ryx showmigrations --dir migrations
python -m ryx showmigrations --unapplied

Options:

FlagPurpose
--dir DIRMigrations directory
--unappliedShow only unapplied migrations

sqlmigrateโ€‹

Print SQL for one migration without executing it.

python -m ryx sqlmigrate 0001_initial --dir migrations
python -m ryx sqlmigrate 0001_initial --backends postgres,mysql,sqlite
python -m ryx sqlmigrate 0001_initial --schema tenant_1

Options:

FlagPurpose
nameMigration name, for example 0001_initial
--dir DIRMigrations directory. Defaults to migrations
--backends LISTComma-separated backend filter: postgres,mysql,sqlite
--schema SCHEMAPostgreSQL schema

flushโ€‹

Delete all rows from all model tables.

python -m ryx --url sqlite:///app.db flush --models myapp.models
python -m ryx --url sqlite:///app.db flush --models myapp.models --yes

Options:

FlagPurpose
--models MODULERequired dotted module path containing models
--yesSkip the confirmation prompt
--forceAlias for --yes
warning

flush is destructive. It issues DELETE FROM "<table>" for every loaded managed model table. Use --yes or --force only in controlled environments.

shellโ€‹

Start an interactive Python shell.

python -m ryx shell --models myapp.models
python -m ryx shell --query "await Post.objects.count()"
python -m ryx shell --notebook

Options:

FlagPurpose
--models MODULEPre-import models from a module
--query, -qExecute a query and print results
--ipyazthonCurrent registered flag for IPython mode
--notebookLaunch Jupyter notebook instead of a shell
note

The code currently registers the IPython flag as --ipyazthon while execution checks ipython. Until that implementation typo is fixed, prefer the plain shell or notebook mode.

dbshellโ€‹

Open the native database command-line client.

python -m ryx --url postgres://user:pass@localhost/app dbshell
python -m ryx --url mysql://user:pass@localhost/app dbshell
python -m ryx --url sqlite:///app.db dbshell
python -m ryx --url sqlite:///app.db dbshell -c ".tables"

Ryx selects the native client from the URL scheme, such as psql, mysql, or sqlite3. The matching CLI tool must be installed on your system.

Options:

FlagPurpose
--command, -c CMDExecute one native database command and exit

inspectdbโ€‹

Introspect an existing database and print Ryx model stubs.

python -m ryx --url postgres://user:pass@localhost/app inspectdb
python -m ryx --url postgres://user:pass@localhost/app inspectdb --table users
python -m ryx --url postgres://user:pass@localhost/app inspectdb --schema tenant_1 -o models.py

Options:

FlagPurpose
--table TABLEIntrospect one table
--output, -o FILEWrite generated model stubs to a file
--schema SCHEMASchema to inspect. Defaults to public

For PostgreSQL/MySQL, Ryx reads information_schema. For SQLite, it falls back to sqlite_master.

versionโ€‹

Print the installed Ryx version.

python -m ryx version
python -m ryx version --verbose

Options:

FlagPurpose
--verbose, -vInclude Rust core version information when available

Pluginsโ€‹

CLI plugins can register extra commands. A plugin implements the Plugin interface and is loaded either from settings/config or Python entry points.

from ryx.cli.plugins import Plugin

class MyPlugin(Plugin):
name = "my-plugin"

def register_commands(self, registry):
registry["mycommand"] = MyCommand

Use plugins when you need project-specific management commands without patching Ryx itself.

Operational Notesโ€‹

  • Use RYX_LOG_LEVEL=debug for verbose query/runtime diagnostics.
  • Use NO_COLOR=1 to disable ANSI colors.
  • Use --no-interactive and makemigrations --check in CI.
  • Prefer --database for migrate; --alias belongs to makemigrations.
  • Use config files for multi-database projects instead of repeating long URL arguments in every command.