Skip to content

Instantly share code, notes, and snippets.

@zyriuse75
Created July 25, 2016 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zyriuse75/ebbc034080046ac40a50efa70843f613 to your computer and use it in GitHub Desktop.
Save zyriuse75/ebbc034080046ac40a50efa70843f613 to your computer and use it in GitHub Desktop.
$LOAD_PATH << '.'
require 'yaml'
require 'rubygems'
require 'mysql2'
require 'pry-byebug'
require 'creatDatabase'
#binding.pry
class StreamMysql
include Sgbd
def mysql_connection(conf)
@connexion = Mysql2::Client.new(:host => conf['ost'], :username => conf['user'], :password => conf['password'], :table => conf['table'], :port => conf['port'])
if @connexion
puts check_table_exists
@connexion.check_table_exists
puts "connexion etablie"
else
puts "error connexion"
end
rescue Mysql2::Error => e
puts e.errno
puts e.error
@connexion.close
end
def read_config_file
config = YAML::load_file(File.join(__dir__, 'config.yml'))
conf = config['database']
mysql_connection(conf)
end
end
SHOW TABLES;
./yamlReadFile.rb:44:in `mysql_connection': undefined method `check_table_exists' for #<Mysql2::Client:0x000000033a7750> (NoMethodError)
module Sgbd
# class ModuleCreateDatabase
def create_database
end
def check_table_exists
query=("SHOW TABLES;")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment