dbping

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 14 Imported by: 0

README

dbping

CI

PING for DB.

Usage

Usage: dbping <dsn> [flags]

Arguments:
  <dsn>    DSN to connect to.
             - MySQL: https://pkg.go.dev/github.com/go-sql-driver/mysql#readme-dsn-data-source-name
             - PostgreSQL: https://pkg.go.dev/github.com/jackc/pgx/v5/stdlib#pkg-overview

Flags:
  -h, --help            Show help.
  -i, --interval=3      Interval seconds.
  -q, --query=STRING    Query to run.
      --iam-auth        Use IAM authentication.
      --version
$ dbping 'root@tcp(127.0.0.1:13306)/mysql'
PING 4ms
PING 1ms
PING 1ms
[ERROR] driver: bad connection
[ERROR] dial tcp 127.0.0.1:13306: connect: connection refused
[ERROR] dial tcp 127.0.0.1:13306: connect: connection refused
PING 6ms
PING 2ms
PING 2ms
...

% dbping 'root@tcp(127.0.0.1:13306)/mysql' -q 'select connection_id()'
11 3ms
11 2ms
11 2ms
...

% dbping 'postgres://postgres@localhost:15432' -q 'select pg_backend_pid()'
68 13ms
68 3ms
68 2ms
...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ping

func Ping(config *Config)

Types

type Config added in v1.1.0

type Config struct {
	DSN      string   `` /* 218-byte string literal not displayed */
	Interval uint     `kong:"short='i',default='3',help='Interval seconds.'"`
	Query    string   `kong:"short='q',help='Query to run.'"`
	IAMAuth  bool     `kong:"help='Use IAM authentication.'"`
	Driver   DBDriver `kong:"-"`
}

func (*Config) OpenDB added in v1.3.0

func (cfg *Config) OpenDB() (*sql.DB, error)

type DBDriver

type DBDriver string
const (
	DBDriverMySQL      DBDriver = "mysql"
	DBDriverPostgreSQL DBDriver = "pgx"
)

Directories

Path Synopsis
cmd
dbping command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL