-
Notifications
You must be signed in to change notification settings - Fork 2
/
mysql.go
33 lines (30 loc) · 864 Bytes
/
mysql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package cmds
import (
"github.com/go-go-golems/clay/pkg/sql"
glazed_cmds "github.com/go-go-golems/glazed/pkg/cmds"
sqleton "github.com/go-go-golems/sqleton/pkg/cmds"
"github.com/spf13/cobra"
)
var MysqlCmd = &cobra.Command{
Use: "mysql",
Short: "MySQL commands",
}
func init() {
// This is an example of how to programmatically create a sqleton query
psCommand, err := sqleton.NewSqlCommand(
glazed_cmds.NewCommandDescription("ps-manual",
glazed_cmds.WithShort("List MySQL processes"),
glazed_cmds.WithLong("SHOW PROCESSLIST"),
),
sqleton.WithDbConnectionFactory(sql.OpenDatabaseFromDefaultSqlConnectionLayer),
sqleton.WithQuery("SHOW PROCESSLIST"),
)
if err != nil {
panic(err)
}
cobraPsCommand, err := sql.BuildCobraCommandWithSqletonMiddlewares(psCommand)
if err != nil {
panic(err)
}
MysqlCmd.AddCommand(cobraPsCommand)
}