我有一个示例字符串“Canon PowerShot 12.1-Megapixel”,当我运行以下代码时,它似乎失败了:
db.execute "CREATE TABLE IF NOT EXISTS Products( id INTEGER PRIMARY KEY, stockID INTEGER, Name TEXT )"
id = 12345
name = "Canon PowerShot 12.1-Megapixel"
db.execute( "INSERT INTO Products ( stockID, Name ) VALUES ( #{id}, #{name} )" )
错误代码是:
C:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6-x86-mingw32/lib/sqlite3/d
atabase.rb:91:in `initialize': near "PowerShot": syntax error
(SQLite3::SQLExcep tion)
from C:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6-x86-mingw32/
lib/sqlite3/database.rb:91:in `new'
from C:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6-x86-mingw32/
lib/sqlite3/database.rb:91:in `prepare'
from C:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.6-x86-mingw32/
lib/sqlite3/database.rb:134:in `execute'
from E:/Documents/Cowboom/scraping/DBDOTDList.rb:48:in `<main>'
知道为什么这会在“PowerShot”之后死掉吗?