mysqlconn 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/README.html +35 -0
  3. data/README.md +40 -0
  4. data/README.md~ +1 -0
  5. data/bin/mysqlconn +35 -0
  6. data/bin/mysqlconn~ +33 -0
  7. metadata +52 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9604068de8e56b612e46401a4cbfb514f281ff9c
4
+ data.tar.gz: b654ac4f6c88ac3bdf8a3314ed865a5090fb1708
5
+ SHA512:
6
+ metadata.gz: f9d69c34766b0a8cc264fa0823e431468f2a8a958ec0595d50906526aa54ea50f4902a32848eebbadd093284a1e7af74961dbfd23a209a9fe95c34a5c3fd0645
7
+ data.tar.gz: 92620a4d05a6a8bd67044b0105ea189d4bfb44a530ef53c2be95bc1282ab5d92f967df54983e504a50d67fa02e7b3763ca90d690288971ce1252f67cac362852
data/README.html ADDED
@@ -0,0 +1,35 @@
1
+ <h1>mysqlconn - The mysql connection assistant</h1>
2
+
3
+ <h3>Instructions</h3>
4
+
5
+ <p>Install:</p>
6
+
7
+ <p><code>gem install mysqlconn</code></p>
8
+
9
+ <p>Create <code>~/.db_connection_alias.yml</code></p>
10
+
11
+ <pre><code>db_key:
12
+ host: hostname
13
+ user: username # Optional
14
+ password: password # Optional
15
+ # password: '' # Optional, prompt for password
16
+ database: database # Optional
17
+ db_key2:
18
+ ...
19
+ </code></pre>
20
+
21
+ <p>Protect configuration file:</p>
22
+
23
+ <p><code>chmod 600 ~/.db_connection_alias.yml</code></p>
24
+
25
+ <h3>Usage</h3>
26
+
27
+ <p>Connect:</p>
28
+
29
+ <p><code>mysqlconn db_key [additional options]</code></p>
30
+
31
+ <p>Pipe:</p>
32
+
33
+ <p><code>mysqlconn db_key &lt; script.sql &gt; output</code></p>
34
+
35
+ <p>etc..</p>
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ mysqlconn - The mysql connection assistant
2
+ ==========================================
3
+
4
+ ### Instructions
5
+
6
+ Install:
7
+
8
+ `gem install mysqlconn`
9
+
10
+ Create `~/.db_connection_alias.yml`
11
+
12
+ db_key:
13
+ host: hostname
14
+ user: username # Optional
15
+ password: password # Optional
16
+ # password: '' # Optional, prompt for password
17
+ database: database # Optional
18
+ db_key2:
19
+ ...
20
+
21
+ Protect configuration file:
22
+
23
+ `chmod 600 ~/.db_connection_alias.yml`
24
+
25
+ ### Usage
26
+
27
+ Connect:
28
+
29
+ `mysqlconn db_key [additional options]`
30
+
31
+ Pipe:
32
+
33
+ `mysqlconn db_key < script.sql > output`
34
+
35
+ etc..
36
+
37
+ ### License
38
+
39
+ MIT - go nuts
40
+
data/README.md~ ADDED
@@ -0,0 +1 @@
1
+ help
data/bin/mysqlconn ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright Neville Kadwa (2014)
4
+
5
+ require 'yaml'
6
+ require 'fileutils'
7
+
8
+ CONFIG_LOCATION=File.expand_path("~/.db_connection_alias.yml")
9
+
10
+ db_key = ARGV.shift || raise('no db key provided. Usage mysqlconn db_key [mysql opts]*')
11
+
12
+ config = begin
13
+ File.open(CONFIG_LOCATION, 'r') do |f|
14
+ YAML.load(f)
15
+ end
16
+ rescue Errno::ENOENT => e
17
+ raise("No config found. Please follow instructions for creating #{CONFIG_LOCATION}")
18
+ end
19
+ raise("Config file is world readable. Exiting...") if File.stat(CONFIG_LOCATION).world_readable?
20
+
21
+ db = config[db_key] || raise("No #{db_key} found")
22
+
23
+ db['host'] || raise("No #{db_key}.host found")
24
+
25
+ command = "mysql -h #{db['host']} --prompt=\"\\u@#{db_key} [\\d]> \""
26
+
27
+ command << " -u #{db['user']}" if db['user']
28
+ command << " -p#{db['password']}" if db['password']
29
+ command << " -D #{db['database']}" if db['database']
30
+ unless ARGV.empty?
31
+ command << " "
32
+ command << ARGV.map{|s| "'#{s}'"}.join(' ')
33
+ end
34
+
35
+ exec(command)
data/bin/mysqlconn~ ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require 'fileutils'
5
+
6
+ CONFIG_LOCATION=File.expand_path("~/.db_connection_alias.yml")
7
+
8
+ db_key = ARGV.shift || raise('no db key provided. Usage mysqlconn db_key [mysql opts]*')
9
+
10
+ config = begin
11
+ File.open(CONFIG_LOCATION, 'r') do |f|
12
+ YAML.load(f)
13
+ end
14
+ rescue Errno::ENOENT => e
15
+ raise("No config found. Please follow instructions for creating #{CONFIG_LOCATION}")
16
+ end
17
+ raise("Config file is world readable. Exiting...") if File.stat(CONFIG_LOCATION).world_readable?
18
+
19
+ db = config[db_key] || raise("No #{db_key} found")
20
+
21
+ db['host'] || raise("No #{db_key}.host found")
22
+
23
+ command = "mysql -h #{db['host']} --prompt=\"\\u@#{db_key} [\\d]> \""
24
+
25
+ command << " -u #{db['user']}" if db['user']
26
+ command << " -p#{db['password']}" if db['password']
27
+ command << " -D #{db['database']}" if db['database']
28
+ unless ARGV.empty?
29
+ command << " "
30
+ command << ARGV.map{|s| "'#{s}'"}.join(' ')
31
+ end
32
+
33
+ exec(command)
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mysqlconn
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Neville Kadwa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Save your various database credentials to a configuration file and zip
14
+ around easily
15
+ email:
16
+ - neville@kadwa.com
17
+ executables:
18
+ - mysqlconn
19
+ - mysqlconn~
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - README.html
24
+ - README.md
25
+ - README.md~
26
+ - bin/mysqlconn
27
+ - bin/mysqlconn~
28
+ homepage: http://github.com/kadwanev/mysqlconn
29
+ licenses:
30
+ - Apache-2.0
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.2.2
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: mysql command line configuration assistant
52
+ test_files: []