forked from tardate/mysql2postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmysql2psql.rb
41 lines (32 loc) · 919 Bytes
/
mysql2psql.rb
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
34
35
36
37
38
39
40
41
require 'mysql2psql/errors'
require 'mysql2psql/version'
require 'mysql2psql/config'
require 'mysql2psql/converter'
require 'mysql2psql/mysql_reader'
require 'mysql2psql/writer'
require 'mysql2psql/postgres_writer'
require 'mysql2psql/postgres_db_writer.rb'
require 'mysql2psql/postgres_file_writer.rb'
class Mysql2psql
attr_reader :options, :reader, :writer
def initialize(args)
help if args.length==1 && args[0] =~ /^-.?|^-*he?l?p?$/i
configfile = args[0] || File.expand_path('mysql2psql.yml')
@options = Config.new( configfile, true )
end
def convert
@reader = MysqlReader.new( options )
if options.destfile(nil)
@writer = PostgresFileWriter.new(options.destfile)
else
@writer = PostgresDbWriter.new(options)
end
Converter.new(reader, writer, options).convert
end
def help
puts <<EOS
MySQL to PostgreSQL Conversion
EOS
exit -2
end
end