class Samidare::MySQL::MySQLClient
Constants
- COLUMN_SQL
Public Class Methods
new(database_config)
click to toggle source
# File lib/samidare/mysql.rb, line 18 def initialize(database_config) @database_config = database_config end
Public Instance Methods
client()
click to toggle source
# File lib/samidare/mysql.rb, line 22 def client @client ||= Mysql2::Client.new( :host => @database_config['host'], :username => @database_config['username'], :password => @database_config['password'], :database => @database_config['database']) end
columns(table_name)
click to toggle source
# File lib/samidare/mysql.rb, line 35 def columns(table_name) rows = client.xquery(COLUMN_SQL, @database_config['database'], table_name) rows.map { |row| Column.new(row['column_name'], row['data_type']) } end
generate_bq_schema(table_name)
click to toggle source
# File lib/samidare/mysql.rb, line 30 def generate_bq_schema(table_name) infos = columns(table_name) BigQueryUtility.generate_schema(infos) end