Skip to content

Instantly share code, notes, and snippets.

@FatihDurmus

FatihDurmus/file.rb

Created Feb 5, 2021
Embed
What would you like to do?
database example
require 'rubygems'
require 'sqlite3'
require 'thread'
def emailSave(email)
#db = SQLite3::Database.open 'data.db'
#db.results_as_hash = true
#query = db.prepare" select * from datas"
#result = query.execute
#result.each do |row|
#puts row['email']
db = SQLite3::Database.open 'data.db'
db.results_as_hash = true
query = db.prepare" INSERT INTO datas (email)
VALUES ('#{email}');"
result = query.execute
#end
end
def passwordSave(password)
#db = SQLite3::Database.open 'data.db'
#db.results_as_hash = true
#query = db.prepare" select * from datas"
#result = query.execute
#result.each do |row|
#puts row['email']
db = SQLite3::Database.open 'data.db'
db.results_as_hash = true
query = db.prepare" INSERT INTO datas (password)
VALUES ('#{password}');"
result = query.execute
#end
end
def divided_data
File.open("email.txt", "r") do |f|
f.each_line do |line|
email = Array(line.split(/: */))
#puts $email[0]
t1 = Thread.new{emailSave(email.first(1))}
File.open("passowrd.txt", "r") do |g|
g.each_line do |pass|
password = Array.new
password = Array(pass.split(/: */))
t2 = Thread.new{passwordSave(password[1])}
end
end
#data = line.split(":", 3).to_s
#result = data.split(/: */).to_s
#puts line
t1.join
t2.join
#puts $email.first
#puts $password.first()
#dbTest($email.first,$password)
#File.open("full_data.txt", 'a') { |file| file.write(email.first+":"+" \n ") }
#File.open("md5_compare.txt",'a'){ |file| file.write(data[0]+"\n")}
end
end
end
divided_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment