I am using sqlite3 and attempting to pass bind variables into SQL statements in a command line application that I'm attempting as a replication of http://www.pangloss.com/seidel/shake_rule.html . This is the management utility for adding/removing from the database. I'm just trying to get an understanding of using SQL with Ruby and building a pen-and-paper rpg utility set for a DM whose game I'm currently playing.
db.execute ("INSERT INTO insults (position, string) VALUES (?, ?);", cmd_args[1].to_i, cmd_args[2])
db.execute("SELECT * FROM insults WHERE position = ? AND string = ?;", cmd_args[1].to_i, cmd_args[2]) do |output|
puts output
end
The first query causes a syntax error "unexpected ',', expecting ')'" and more errors which follow, but they disappear when I comment this line out.
The latter query does not seem fundamentally different, but it causes no errors when I comment out the former. It still does not output anything when I set the cmd_args array values manually. The database has some test elements in it, i.e. "1|test" which do not output, though no error is thrown.