Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8434693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:43:38+00:00 2026-06-10T06:43:38+00:00

I am using sqlite3 and attempting to pass bind variables into SQL statements in

  • 0

I am using sqlite3 and attempting to pass bind variables into SQL statements in a command line application that I’m attempting as a replication of http://www.pangloss.com/seidel/shake_rule.html . This is the management utility for adding/removing from the database. I’m just trying to get an understanding of using SQL with Ruby and building a pen-and-paper rpg utility set for a DM whose game I’m currently playing.

db.execute ("INSERT INTO insults (position, string) VALUES (?, ?);",    cmd_args[1].to_i, cmd_args[2])

db.execute("SELECT * FROM insults WHERE position = ? AND string = ?;", cmd_args[1].to_i, cmd_args[2]) do |output|
  puts output
end

The first query causes a syntax error “unexpected ‘,’, expecting ‘)'” and more errors which follow, but they disappear when I comment this line out.

The latter query does not seem fundamentally different, but it causes no errors when I comment out the former. It still does not output anything when I set the cmd_args array values manually. The database has some test elements in it, i.e. “1|test” which do not output, though no error is thrown.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:43:39+00:00Added an answer on June 10, 2026 at 6:43 am

    You can’t have a space between the method name and the opening parenthesis. Your first one:

    db.execute ("INSERT INTO insults (position, string) VALUES (?, ?);",    cmd_args[1].to_i, cmd_args[2])
    

    is interpreted more like this:

    x = ("INSERT ....", cms_args[1].to_i, cmd_args[2])
    db.execute x
    

    but constructs like (a, b, c) aren’t legal Ruby syntax in that context and there’s your syntax error.

    Your second one:

    db.execute("SELECT * ...", cmd_args[1].to_i, cmd_args[2]) do |output|
      puts output
    end
    

    should work fine so, presumably, your WHERE clause doesn’t match anything so you don’t get any results. Examine the contents of cmd_args and make sure that:

    1. You don’t have any stray whitespace.
    2. Your arguments really are in cmd_args[1..2] rather than cmd_args[0..1].
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQLite3, and the SQLite3 class that's built into PHP. The following code
in sqlite3 using the command line, if I want to enter something very approximate
Using sqlite3, I have a table that looks like this: +---------+-----------------+----------+-----------+--------+ | ArtId |
I am switching from using SQLite3 to PostgreSQL, and hoped that I could populate
hi i am working on a django python application using sqlite3 database. I have
I have created a file named MyFile.db using SQLite3 from my C#.net application. This
I have been happily developing my application locally and using sqlite3 as database only
I have a sqlite database that I want to open using sqlite3.exe. Now I
I have a database winforms application using SQLite written in C#. I'm attempting to
I've made a web application using SQLite (2.8.17), I've only now discovered that there's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.