Skip to content

feat: add pgdog psql CLI subcommand#1097

Open
murex971 wants to merge 1 commit into
pgdogdev:mainfrom
murex971:nagrawal-psql
Open

feat: add pgdog psql CLI subcommand#1097
murex971 wants to merge 1 commit into
pgdogdev:mainfrom
murex971:nagrawal-psql

Conversation

@murex971

Copy link
Copy Markdown
Contributor

Adds a psql subcommand that opens an interactive psql shell (or runs a psql command) directly against a backend database defined in pgdog.toml.

Usage

# interactive shell
pgdog psql --database prod --user pgdog
# run a single statement
pgdog psql --database prod --user pgdog -- -c "SELECT version()"
# run a SQL file
pgdog psql --database prod --user pgdog -- -f migration.sql
# connect to a specific shard
pgdog psql --database prod --user pgdog --shard 1

Any flags after -- are forwarded verbatim to psql.

closes #430

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 81 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pgdog/src/cli.rs 0.00% 70 Missing ⚠️
pgdog/src/main.rs 0.00% 11 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread pgdog/src/cli.rs
extra_args: &[String],
config: &ConfigAndUsers,
) -> Result<(), Box<dyn std::error::Error>> {
use std::os::unix::process::CommandExt;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that'll break the compilation on non unix platforms. Although, it's not our main target we'd prefer the pgdog to be buildable on most platforms.
Let's think how we can avoid this platform-specific features or gate it behind cfg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open psql shell to a database

2 participants