Class: Flydata::SourceMysql::SyncDatabaseSizeCheck

Inherits:
Object
  • Object
show all
Includes:
MysqlAccessible
Defined in:
lib/flydata/source_mysql/sync_database_size_check.rb

Constant Summary collapse

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

Instance Method Summary collapse

Methods included from MysqlAccessible

#build_mysql_db_opts, #exec_mysql_query, #mysql_client

Constructor Details

#initialize(de_conf) ⇒ SyncDatabaseSizeCheck

Returns a new instance of SyncDatabaseSizeCheck.


17
18
19
20
21
22
# File 'lib/flydata/source_mysql/sync_database_size_check.rb', line 17

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

Instance Method Details

#get_db_bytesizeObject


24
25
26
# File 'lib/flydata/source_mysql/sync_database_size_check.rb', line 24

def get_db_bytesize
  exec_mysql_query(@query).first['bytesize'].to_i
end