I am writing a script that ports results into a sqlite database. I can not get the code to work when I use variables. here is an excerpt.
require 'sqlite3'
require 'shodan'
table_name = "#{Date.today.strftime("%B")}#{Time.now.year}_Findings" db = SQLite3::Database.new "shodan_test.db"
db.execute ("CREATE TABLE #{table_name} (ip string , ports string)")
results = api.host(target)
ip = results["ip_str"].to_s
ports = results["ports"].to_s
db.execute ("insert into #{table_name} (ip, ports) values (#{ip}, #{ports})")
The code fails at the last line. I can remove the variable ref and the code works. I'm a bit confused since the CREATE TABLE works with a variable.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire