2017-01-31 14:38:08 +00:00
|
|
|
require 'mysql2'
|
|
|
|
|
|
|
|
load 'config.rb'
|
|
|
|
|
|
|
|
db = Mysql2::Client.new(:host => DB_HOST, :username => DB_USER, :database => DB_DB)
|
|
|
|
|
2017-01-30 13:06:38 +00:00
|
|
|
person = ARGV[0]
|
|
|
|
product = ARGV[1]
|
|
|
|
amount = ARGV[2]
|
|
|
|
log_dir = "./log/"
|
|
|
|
|
|
|
|
amount = 1.0 unless amount
|
|
|
|
|
2017-01-31 14:38:08 +00:00
|
|
|
statement = db.prepare("INSERT INTO transactions (buyer, product, amount) VALUES (?, ?, ?)")
|
|
|
|
result = statement.execute(person,product,amount)
|
|
|
|
puts result
|
|
|
|
|
|
|
|
#output = File.open("#{log_dir}/matkant-#{Time.now.strftime('%Y%W')}.log","a+")
|
|
|
|
#output << "#{Time.now.to_i};#{person};#{product};#{amount}\n"
|
|
|
|
#output.close
|