db = Extralite::Database.new('/tmp/my.db')
stmt = db.prepare('select name from users where id = ?')
stmt.class #=> Extralite::PreparedStatement
# PreparedStatement has more or less the same querying interface as Database
stmt.query(42) # id=42
stmt.query_single_value(42)
# ...etc
In terms of implementation, very little change is needed to the code dealing with running queries. We just need to keep the sqlite3_stmt struct in the PreparedStatement object, instead of throwing it away.
Sketch for interface
In terms of implementation, very little change is needed to the code dealing with running queries. We just need to keep the
sqlite3_stmt
struct in thePreparedStatement
object, instead of throwing it away.