Class: Flydata::Parser::Mysql::DatabaseSizeCheck

Inherits:
Object
  • Object
show all
Includes:
MysqlAccessible
Defined in:
lib/flydata/parser/mysql/dump_parser.rb

Constant Summary collapse

SIZE_CHECK_QUERY =
<<EOT
SELECT
  SUM(data_length) bytesize
FROM
  information_schema.tables
WHERE
  table_schema NOT IN ('information_schema','performance_schema','mysql') AND table_name in (%s);
EOT

Instance Method Summary collapse

Methods included from MysqlAccessible

#mysql_cli, #mysql_conf

Constructor Details

#initialize(de_conf) ⇒ DatabaseSizeCheck

Returns a new instance of DatabaseSizeCheck.


638
639
640
641
642
# File 'lib/flydata/parser/mysql/dump_parser.rb', line 638

def initialize(de_conf)
  @de_conf = de_conf
  @tables = de_conf['tables']
  @query = SIZE_CHECK_QUERY % [@tables.collect{|t| "'#{t}'"}.join(',')]
end

Instance Method Details

#get_db_bytesizeObject


644
645
646
647
648
649
650
# File 'lib/flydata/parser/mysql/dump_parser.rb', line 644

def get_db_bytesize
  client = mysql_cli(@de_conf)
  result = client.query(@query)
  return result.first['bytesize'].to_i
ensure
  client.close rescue nil
end