Ruby on Rails - get MySql DB size -


i want know current size of mysql db, data use following methods:

def self.calculate_total_db_size     sql = "select table_schema 'database',                   sum( data_length + index_length ) / ( 1024 *1024 ) size                   information_schema.tables                   engine=('myisam' || 'innodb' )                   , table_schema = '#{get_current_db_name}'"     return  perform_sql_query(sql)   end    def self.get_current_db_name         return rails.configuration.database_configuration[rails.env]["database"] end  def self.perform_sql_query(query)      result = []      mysql_res = activerecord::base.connection.execute(query)      mysql_res.each_hash{ |res| result << res }      return result end 

this works great in development , staging environment, reason when run in production query doesnt return value, if take mysql query , run manually on production db correct values. why cant through application in production?

any thoughts?

i added more logs , helped me pinpoint problem, using: rails.configuration.database_configuration[rails.env]["database"] returns empty string when in production , not in other environment, guess because in database.yml there's link development setting under production (what makes production settings same dev). anyway, since dont want change database.yml file changed way im getting database name. works great.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -