digital-fabric / extralite

Ruby on SQLite
http://www.rubydoc.info/gems/extralite
MIT License
255 stars 8 forks source link

Add prepared statements #7

Closed noteflakes closed 2 years ago

noteflakes commented 2 years ago

Sketch for interface

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.