Skip to content
This repository

added another insert example to readme #72

Merged
merged 2 commits into from over 1 year ago

3 participants

Kevin Curtin Aaron Patterson Adam Jonas
Kevin Curtin

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!

README.rdoc
@@ -33,6 +33,10 @@ Note that this module is only compatible with SQLite 3.6.16 or newer.
33 33
   }.each do |pair|
34 34
     db.execute "insert into numbers values ( ?, ? )", pair
35 35
   end
  36
+
  37
+  # Execute multi-inserts
  38
+  db.execute("INSERT INTO students (name, email, grade, blog) 
  39
+              VALUES (?, ?, ?, ?)", @name, @email, @grade, @blog)
1
Aaron Patterson Owner

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
Aaron Patterson
Owner

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

Adam Jonas
Kevin Curtin

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 :)

Aaron Patterson
Owner

Awesome, thanks @kcurtin!

Aaron Patterson tenderlove merged commit 4bf746d into from October 12, 2012
Aaron Patterson tenderlove closed this October 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Oct 11, 2012
Kevin Curtin added a multi-insert example to readme 8e934ac
Oct 12, 2012
Kevin Curtin changed example description and syntax 37c01ba
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  README.rdoc
4  README.rdoc
Source Rendered
@@ -33,6 +33,10 @@ Note that this module is only compatible with SQLite 3.6.16 or newer.
33 33
   }.each do |pair|
34 34
     db.execute "insert into numbers values ( ?, ? )", pair
35 35
   end
  36
+
  37
+  # Execute inserts with parameter markers
  38
+  db.execute("INSERT INTO students (name, email, grade, blog) 
  39
+              VALUES (?, ?, ?, ?)", [@name, @email, @grade, @blog])
36 40
   
37 41
   # Find a few rows
38 42
   db.execute( "select * from numbers" ) do |row|
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.