mysqlconn 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/README.md~ +7 -0
- data/lib/mysqlconn.rb +17 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18cb53723bc90c29c7fa83666e2beae7bb7f1870
|
4
|
+
data.tar.gz: 6d59dac39738ab1a3046282cd40232e48fd9ab86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7139919e8301d43aa97f2a307e9ae45824eb562d59cc4bcacb5cdfcbf6b74f063f862c3ceba8db97b034b93ef5cb7bfda66492958af90af3cc9ed6cf33192a7d
|
7
|
+
data.tar.gz: 7a1de07abe3e0c3a843966e2787fd616f1e70ca4b4875c55a64595dec8ab80723de4a28a311e438293e79880d6efb526993bfbaaebba84db9eba4128b8ca725b
|
data/README.md
CHANGED
@@ -13,6 +13,10 @@ Install:
|
|
13
13
|
|
14
14
|
Create `~/.db_connection_alias.yml`
|
15
15
|
|
16
|
+
config:
|
17
|
+
default_arg: # any desired default arguments
|
18
|
+
# mysql: -A
|
19
|
+
mysqldump: --quick --single-transaction
|
16
20
|
db_key:
|
17
21
|
host: hostname
|
18
22
|
port: port # Optional
|
@@ -55,6 +59,9 @@ To mysqldump:
|
|
55
59
|
|
56
60
|
`mysqldumpconn db_key [additional options]`
|
57
61
|
|
62
|
+
Verbose:
|
63
|
+
|
64
|
+
Add `-v` BEFORE the db_key to print out the final executed command to STDERR. BEWARE: It will print plain password.
|
58
65
|
|
59
66
|
### Autocomplete
|
60
67
|
|
@@ -65,6 +72,7 @@ Add to bash.completion.d or wherever:
|
|
65
72
|
COMPREPLY=( $( compgen -W "$(mysqlconn -l)" -- $cur ) )
|
66
73
|
}
|
67
74
|
complete -F _mysqlconn mysqlconn
|
75
|
+
complete -F _mysqlconn mysqldumpconn
|
68
76
|
|
69
77
|
### License
|
70
78
|
|
data/README.md~
CHANGED
@@ -15,6 +15,7 @@ Create `~/.db_connection_alias.yml`
|
|
15
15
|
|
16
16
|
db_key:
|
17
17
|
host: hostname
|
18
|
+
port: port # Optional
|
18
19
|
user: username # Optional
|
19
20
|
password: password # Optional
|
20
21
|
# password: '' # Optional, prompt for password
|
@@ -33,6 +34,7 @@ Connect:
|
|
33
34
|
`mysqlconn db_key [additional options]`
|
34
35
|
|
35
36
|
Look at that beautiful prompt:
|
37
|
+
|
36
38
|
mysqluser@db_key [database]> select now();
|
37
39
|
+---------------------+
|
38
40
|
| now() |
|
@@ -49,6 +51,11 @@ Pipe:
|
|
49
51
|
|
50
52
|
etc..
|
51
53
|
|
54
|
+
To mysqldump:
|
55
|
+
|
56
|
+
`mysqldumpconn db_key [additional options]`
|
57
|
+
|
58
|
+
|
52
59
|
### Autocomplete
|
53
60
|
|
54
61
|
Add to bash.completion.d or wherever:
|
data/lib/mysqlconn.rb
CHANGED
@@ -11,6 +11,7 @@ class MysqlConn
|
|
11
11
|
CONFIG_LOCATION=File.expand_path("~/.db_connection_alias.yml")
|
12
12
|
|
13
13
|
attr_reader :mode
|
14
|
+
attr_reader :config
|
14
15
|
attr_reader :verbose
|
15
16
|
attr_reader :db_key
|
16
17
|
|
@@ -33,9 +34,19 @@ class MysqlConn
|
|
33
34
|
def mode_default_args(args)
|
34
35
|
case mode
|
35
36
|
when :MYSQL
|
36
|
-
"--prompt=\"\\u@#{db_key} [\\d]> \""
|
37
|
+
"--prompt=\"\\u@#{db_key} [\\d]> \" " <<
|
38
|
+
if config['config'] && config['config']['default_arg'] && config['config']['default_arg']['mysql']
|
39
|
+
config['config']['default_arg']['mysql']
|
40
|
+
else
|
41
|
+
""
|
42
|
+
end
|
43
|
+
|
37
44
|
when :MYSQLDUMP
|
38
|
-
|
45
|
+
if config['config'] && config['config']['default_arg'] && config['config']['default_arg']['mysqldump']
|
46
|
+
config['config']['default_arg']['mysqldump']
|
47
|
+
else
|
48
|
+
""
|
49
|
+
end
|
39
50
|
else
|
40
51
|
raise "Unknown mode: #{mode}"
|
41
52
|
end
|
@@ -45,7 +56,7 @@ class MysqlConn
|
|
45
56
|
|
46
57
|
@db_key = args.shift || raise('no db key provided. Usage mysqlconn db_key [mysql opts]*')
|
47
58
|
|
48
|
-
config = begin
|
59
|
+
@config = begin
|
49
60
|
File.open(CONFIG_LOCATION, 'r') do |f|
|
50
61
|
YAML.load(f)
|
51
62
|
end
|
@@ -61,7 +72,9 @@ class MysqlConn
|
|
61
72
|
if db_key == '-l'
|
62
73
|
filter = /.*#{args.shift||'.*'}.*/
|
63
74
|
config.keys.each do |k|
|
64
|
-
|
75
|
+
if k != 'config' && filter =~ k
|
76
|
+
puts k
|
77
|
+
end
|
65
78
|
end
|
66
79
|
exit(0)
|
67
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysqlconn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neville Kadwa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Save your various database credentials to a configuration file and zip
|
14
14
|
around easily
|