谷歌搜索了大约半天,我找不到任何使用 pg gem(postgresql ruby gem)准备好的 INSERT 语句的样本。
我试过这个(在查看 gem 文档之后):
def test2
conn = PG.connect( dbname: 'db1' )
conn.prepare("statement1", 'INSERT INTO table1 (id, name, profile) VALUES (?, ?, ?)')
end
但我收到以下错误:
pgtest.rb:19:in `prepare': ERROR: syntax error at or near "," (PG::Error)
LINE 1: INSERT INTO table1 (id, name, profile) VALUES (?, ?, ?)
^
from pgtest.rb:19:in `test2'
from pgtest.rb:25:in `<main>'