Sha256: 735beb8e7786397f65ac860a569c1c89ec94fb6a241a87d44b78a06ff758d5d9

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'sqlite2mysql/version'
require 'sqlite2mysql/services/arguments'
require 'sqlite2mysql/services/bound_finder'
require 'sqlite2mysql/services/mysql'
require 'sqlite2mysql/services/sqlite'
require 'sqlite2mysql/services/type_inferrer'

class Sqlite2Mysql
  class << self
    def run(args)
      arguments = Arguments.new(args)

      puts 'Collecting Sqlite3 Info'

      db = SqliteClient.new(arguments.sqlite_db, infer_column_types: arguments.infer_types)

      schema = db.build_schema

      puts "Creating MySQL DB: #{arguments.mysql_db}"

      mysql = MysqlClient.new(
        host:     arguments.mysql_host,
        username: arguments.username,
        password: arguments.password,
        port:     arguments.mysql_port)
      mysql.recreate(arguments.mysql_db)
      mysql.build_from_schema(schema)

      print 'Grab a ☕'

      schema.keys.each do |table|
        puts "\nInserting data: #{table}"
        data = db.get_data(table)
        mysql.insert_table(table, data)
      end
      puts ''
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sqlite2mysql-0.2.0 lib/sqlite2mysql.rb