dbping

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 13 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.
  -t, --timeout=3       Timeout seconds.
  -q, --query=STRING    Query to run.
      --iam-auth        Use IAM authentication.
      --version
$ dbping 'root@tcp(127.0.0.1:13306)/mysql'
12:27:43 | PING 4ms
12:27:47 | PING 1ms
12:27:50 | 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
12:28:02 | PING 6ms
12:28:05 | PING 2ms
12:28:08 | PING 2ms
...

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

% dbping 'postgres://postgres@localhost:15432' -q 'select pg_backend_pid()'
12:29:39 | 68 13ms
12:29:42 | 68 3ms
12:29:45 | 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.'"`
	Timeout  uint     `kong:"short='t',default='3',help='Timeout 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