<commit_before>#!/usr/bin/env ruby

require 'optparse'
require 'mysql2'
require 'io/console'

# Argument definitions
options = {}
optparse = ::OptionParser.new do |opts|
	opts.banner = 'Usage: airooi.rb'

	options[:verbose] = false
	opts.on('-v', '--verbose', 'Print detailed view') do
		options[:verbose] = true
	end

	# Connection params
	options[:host] = "localhost"
	opts.on('-h', '--host=host', 'Database hostname - default to localhost') do |host|
		options[:host] = host
	end
	
	opts.on('-u', '--user=user', 'Database user') do |user|
		options[:user] = user
	end

	opts.on('-p', '--password=password', 'Database password') do |pass|
		options[:pass] = pass
	end

	opts.on('-d', '--database=database', 'Name of the database') do |database|
		options[:database] = database 
	end
end

# Parsing the arguments, and printing an error if they are missing
begin
	optparse.parse!
	mandatory = [:host, :user, :database]
	missing = mandatory.select{ |param| options[param].nil? }
	if not missing.empty?
		puts "Missing options: #{missing.join(', ')}"
		puts optparse
		exit
	end
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
	puts $!.to_s
	puts optparse
	exit
end

# Ask for a password if it wasn't provided when invoking the script
if not options.has_key?('password')
	begin
		print 'Password: '
		options[:password] = STDIN.noecho(&:gets).gsub("\n", "")
		puts ''
	rescue Interrupt
		puts ''
		exit
	end
end

# Connecting to the database
begin
	client = Mysql2::Client.new(
		:host => options[:host], 
		:username => options[:user],
		:password => options[:password],
	)
	client.select_db(options[:database])
rescue Mysql2::Error => e
	puts "Connection to the database failed: " + e.message
	exit
end

# Read table list
tables = client.query("SHOW TABLES;")
tables.each do |table|
	puts table[table.keys.first]
end



<commit_msg>Temporary commit<commit_after>#!/usr/bin/env ruby

require 'optparse'
require 'mysql2'
require 'io/console'

# Argument definitions
options = {}
optparse = ::OptionParser.new do |opts|
	opts.banner = 'Usage: airooi.rb'

	options[:verbose] = false
	opts.on('-v', '--verbose', 'Print detailed view') do
		options[:verbose] = true
	end

	# Connection params
	options[:host] = "localhost"
	opts.on('-h', '--host=host', 'Database hostname - default to localhost') do |host|
		options[:host] = host
	end
	
	opts.on('-u', '--user=user', 'Database user') do |user|
		options[:user] = user
	end

	opts.on('-p', '--password=password', 'Database password') do |pass|
		options[:pass] = pass
	end

	opts.on('-d', '--database=database', 'Name of the database') do |database|
		options[:database] = database 
	end
end

# Parsing the arguments, and printing an error if they are missing
begin
	optparse.parse!
	mandatory = [:host, :user, :database]
	missing = mandatory.select{ |param| options[param].nil? }
	if not missing.empty?
		puts "Missing options: #{missing.join(', ')}"
		puts optparse
		exit
	end
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
	puts $!.to_s
	puts optparse
	exit
end

# Ask for a password if it wasn't provided when invoking the script
if not options.has_key?('password')
	begin
		print 'Password: '
		options[:password] = STDIN.noecho(&:gets).gsub("\n", "")
		puts ''
	rescue Interrupt
		puts ''
		exit
	end
end

# Connecting to the database
begin
	client = Mysql2::Client.new(
		:host => options[:host], 
		:username => options[:user],
		:password => options[:password],
	)
	client.select_db(options[:database])
rescue Mysql2::Error => e
	puts "Connection to the database failed: " + e.message
	exit
end

# Read table list
tables = client.query("SHOW TABLES;")
tables.each do |table|

	table_name = table[table.keys.first]
	columns = client.query("DESC `#{table_name}`")

	columns.each do |column|
		column_type = column["Type"].downcase
		column_name = column["Field"]
		if ['mediumint', 'int'].any? { |type| column_type.include?(type) }
			puts "#{table_name}.#{column_name} is an int/mediumint"
		end
	end
end




{'fraction_non_alphanumeric': 0.15332666333166584, 'fraction_numerical': 0.0015007503751875938, 'mean_word_length': 4.426051560379919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4751923', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1353, 'n_words': 385}