Business intelligence made simple
Support for MySQL timeouts
Andrew Kane3c88c3dd0c02
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1e52be41..10a7e7a6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,7 @@- Added schedule for checks- Switched to Chart.js for charts- Better output for explain+- Support for MySQL timeouts## 1.2.1diff --git a/lib/blazer/data_source.rb b/lib/blazer/data_source.rbindex 1a946964..6d341020 100644--- a/lib/blazer/data_source.rb+++ b/lib/blazer/data_source.rb@@ -79,7 +79,14 @@ module Blazerin_transaction dobegin- connection_model.connection.execute("SET statement_timeout = #{timeout.to_i * 1000}") if timeout && (postgresql? || redshift?)+ if timeout+ if postgresql? || redshift?+ connection_model.connection.execute("SET statement_timeout = #{timeout.to_i * 1000}")+ elsif mysql?+ connection_model.connection.execute("SET max_execution_time = #{timeout.to_i * 1000}")+ end+ end+result = connection_model.connection.select_all("#{statement} /*#{comment}*/")result.each do |untyped_row|row = {}@@ -119,15 +126,23 @@ module Blazerenddef postgresql?- connection_model.connection.adapter_name == "PostgreSQL"+ ["PostgreSQL", "PostGIS"].include?(adapter_name)enddef redshift?- connection_model.connection.adapter_name == "Redshift"+ ["Redshift"].include?(adapter_name)+ end++ def mysql?+ ["MySQL", "Mysql2", "Mysql2Spatial"].include?(adapter_name)endprotected+ def adapter_name+ connection_model.connection.adapter_name+ end+def in_transactionif use_transaction?connection_model.transaction dodiff --git a/lib/generators/blazer/templates/config.yml b/lib/generators/blazer/templates/config.ymlindex 447735e8..b45a1904 100644--- a/lib/generators/blazer/templates/config.yml+++ b/lib/generators/blazer/templates/config.yml@@ -5,7 +5,6 @@ data_sources:url: <%%= ENV["BLAZER_DATABASE_URL"] %># statement timeout, in seconds- # applies to PostgreSQL only# none by default# timeout: 15