Skip to content

Loading…

added another insert example to readme #72

Merged
merged 2 commits into from

3 participants

@kcurtin

a group of new programmers used this gem for a project today. We didn't realize that it supported the multi-insert syntax included here and a bunch of us ended up jumping through hoops and manually escaping characters ourselves. Added an example to README to make it clear this feature is supported.

Thanks!

@tenderlove tenderlove commented on an outdated diff
README.rdoc
@@ -33,6 +33,10 @@ Note that this module is only compatible with SQLite 3.6.16 or newer.
}.each do |pair|
db.execute "insert into numbers values ( ?, ? )", pair
end
+
+ # Execute multi-inserts
+ db.execute("INSERT INTO students (name, email, grade, blog)
+ VALUES (?, ?, ?, ?)", @name, @email, @grade, @blog)
@tenderlove Sparkle Motion member

This is deprecated. It should be like this:

db.execute("INSERT INTO students (name, email, grade, blog)
                       VALUES (?, ?, ?, ?)", [@name, @email, @grade, @blog])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@tenderlove
Sparkle Motion member

@ajonas04 what? @kcurtin opened this pull request less than 30min ago. o_O

@adamjonas
@kcurtin

i was using a very old version of sqlite3, and didn't even know. I updated the example with the changed syntax and changed the wording of the description :)

@tenderlove
Sparkle Motion member

Awesome, thanks @kcurtin!

@tenderlove tenderlove merged commit 4bf746d into sparklemotion:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2012
  1. @kcurtin
  2. @kcurtin
Showing with 4 additions and 0 deletions.
  1. +4 −0 README.rdoc
View
4 README.rdoc
@@ -33,6 +33,10 @@ Note that this module is only compatible with SQLite 3.6.16 or newer.
}.each do |pair|
db.execute "insert into numbers values ( ?, ? )", pair
end
+
+ # Execute inserts with parameter markers
+ db.execute("INSERT INTO students (name, email, grade, blog)
+ VALUES (?, ?, ?, ?)", [@name, @email, @grade, @blog])
# Find a few rows
db.execute( "select * from numbers" ) do |row|
Something went wrong with that request. Please try again.