Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

- new: set the default fetch size to 100 for postgresql and db2

- new: added --fetch option to manually specify the fetch size
- update: README has new usage
  • Loading branch information...
commit fb0bb411c07b1d0dc558462ce9bbf446b1ca0287 1 parent 0bbc43f
@fsfiii authored
Showing with 16 additions and 2 deletions.
  1. +2 −0  CHANGELOG
  2. +2 −0  README
  3. +12 −2 bin/nosqoop4u.rb
View
2  CHANGELOG
@@ -1,6 +1,8 @@
* 2011-07-15 - fsf
- new: added --driver option to manually specify jdbc class to load
- new: added auto db2 driver load for jdbc:db2: URIs
+- new: set the default fetch size to 100 for postgresql and db2
+- new: added --fetch option to manually specify the fetch size
* 2011-07-02 - fsf
- initial import
View
2  README
@@ -31,8 +31,10 @@ usage: nosqoop4u options
-c, --connect url # jdbc connection url (env NS4U_URL)
-u, --user # db username (env NS4U_USER)
-p, --pass # db password (env NS4U_PASS)
+ -d, --driver # JDBC driver class (env NS4U_DRIVER)
-e, --query # sql query to run
-F, --delim # delimiter (default: ^A)
+ -f, --fetch # fetch size
-h, --help
Please let me know if you find this software useful!
View
14 bin/nosqoop4u.rb
@@ -11,9 +11,10 @@ def usage
-c, --connect url # jdbc connection url (env NS4U_URL)
-u, --user # db username (env NS4U_USER)
-p, --pass # db password (env NS4U_PASS)
+ -d, --driver # JDBC driver class (env NS4U_DRIVER)
-e, --query # sql query to run
-F, --delim # delimiter (default: ^A)
- -d, --driver # JDBC driver class to load
+ -f, --fetch # fetch size
-h, --help
EOF
end
@@ -26,6 +27,7 @@ def initialize cfg
@db_host = cfg[:db_host] || ENV['NS4U_HOST']
@db_name = cfg[:db_name] || ENV['NS4U_DB']
@driver = cfg[:driver] || ENV['NS4U_DRIVER']
+ @fetch = cfg[:fetch]
load_driver
connect
@@ -43,10 +45,15 @@ def hack_jdbc
when /jdbc:postgresql:/
@conn.set_auto_commit false
@stmt = @conn.create_statement
- @stmt.fetch_size = 50
+ @stmt.fetch_size = 100
+ when /jdbc:db2:/
+ @stmt = @conn.create_statement
+ @stmt.fetch_size = 100
else
@stmt = @conn.create_statement
end
+
+ @stmt.fetch_size = @fetch if @fetch
end
def load_driver
@@ -203,6 +210,9 @@ def o.puts s
opts[:delim] = arg
when '--driver'
opts[:driver] = arg
+ when '--fetch'
+ opts[:fetch] = arg.to_i
+ opts[:fetch] = nil if opts[:fetch] < 1
when '--query'
sql = arg
when '--help'
Please sign in to comment.
Something went wrong with that request. Please try again.