-
-
Save zyriuse75/ebbc034080046ac40a50efa70843f613 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHOW TABLES; | |
./yamlReadFile.rb:44:in `mysql_connection': undefined method `check_table_exists' for #<Mysql2::Client:0x000000033a7750> (NoMethodError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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