Sha256: 8210e4b15a3c92b09855614ece79390aad33d2c6eaebf68047d13cbdb68be6f3

Contents?: true

Size: 1.65 KB

Versions: 110

Compression:

Stored size: 1.65 KB

Contents

#!/usr/bin/env ruby

#require 'optparse'

lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'flydata/table_def'

# Deprecation warning
$stderr.puts "WARNING: Use 'flydata sync:generate_table_ddl' command instead"

if `which mysqldump`.empty?
  abort "mysqldump is not installed."
end

# TODO Implement options instead of passing all to mysqldump.
=begin
opts = {}

op = OptionParser.new do |o|
  o.on('-h', '--host NAME', 'Connect to host.') do |v|
    opts[:host] = v
  end
  o.on('-P', '--port NUMBER', 'Port number to use for connection.') do |v|
    opts[:port] = v
  end
  o.on('-u', '--user NAME', 'User for login if not current user.') do |v|
    opts[:user] = v
  end
  o.on('-p', '--password [TEXT]', "Password to use when connecting to server.  If password is not given it's solicited on the tty.") do |v|
    opts[:password] = v
  end
end

op.parse!

=end
command = "mysqldump -d"

=begin
command += " -u#{opts[:user]}" if opts[:user]
command += " -h#{opts[:host]}" if opts[:host]
command += " -P#{opts[:port]}" if opts[:port]
command += " -p#{opts[:password]}" if opts[:password]
=end
command += " " + ARGV.join(' ')

IO.popen(command, 'r') do |io|
  create_flydata_ctl_table = true
  while !io.eof?
    mysql_tabledef = Flydata::TableDef::MysqlTableDef.create(io)
    if mysql_tabledef.nil?
      # stream had no more create table definition
      break
    end
    flydata_tabledef = mysql_tabledef.to_flydata_tabledef
    puts Flydata::TableDef::RedshiftTableDef.from_flydata_tabledef(flydata_tabledef, flydata_ctl_table: create_flydata_ctl_table)
    create_flydata_ctl_table = false
  end
end

Version data entries

110 entries across 110 versions & 1 rubygems

Version Path
flydata-0.7.2.1 bin/fdmysqldump
flydata-0.7.2 bin/fdmysqldump
flydata-0.7.1 bin/fdmysqldump
flydata-0.7.0 bin/fdmysqldump
flydata-0.6.14 bin/fdmysqldump
flydata-0.6.13 bin/fdmysqldump
flydata-0.6.12 bin/fdmysqldump
flydata-0.6.11 bin/fdmysqldump
flydata-0.6.10 bin/fdmysqldump
flydata-0.6.9 bin/fdmysqldump
flydata-0.6.8 bin/fdmysqldump
flydata-0.6.7 bin/fdmysqldump
flydata-0.6.6 bin/fdmysqldump
flydata-0.6.5 bin/fdmysqldump
flydata-0.6.4 bin/fdmysqldump
flydata-0.6.3 bin/fdmysqldump
flydata-0.6.2 bin/fdmysqldump
flydata-0.6.1 bin/fdmysqldump
flydata-0.6.0 bin/fdmysqldump
flydata-0.5.21 bin/fdmysqldump