-
-
Save 0x0dea/240bc27ccdea6ba377f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sqlite3' | |
db = SQLite3::Database.new ':memory:' | |
db.execute_batch <<SQL | |
CREATE TABLE people (name TEXT, age INTEGER); | |
INSERT INTO people VALUES ('Alice', 20), ('Bob', 23); | |
SQL | |
stmt = db.prepare 'SELECT * FROM people WHERE name = ?' | |
name = 'Alice' | |
stmt.bind_param 1, name | |
p stmt.execute.next # => ["Alice", 20] | |
name.replace 'Bob' | |
p stmt.execute.next # => ["Alice", 20] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment