==== SUMMARY ====
DBI::DatabaseHandle#do should be able to run multiple queries for DBD-Pg as it is supported in the native Pg driver.
Currently, it fails with the following error:
ERROR: cannot insert multiple commands into a prepared
==== DETAILS ====
DBI::DatabaseHandle#do should *not* prepare queries and should allow executing multiple queries. The documentation states:
"(DatabaseHandle#do) goes straight to the DBD‘s implementation, and does *not* work like execute and
prepare.".
Pg sql, on which DBD-pg is based, supports multiple queries.
Code snippet:
require 'pg'
require 'dbd/pg'
require 'dbi'
# Pg Succeeds
PGconn.new({:host=>host,:user=>user,:password=>password,
:dbname=>dbname})
do |conn|
conn.exec("select 1; select 1;")
end
# DBD-Pg Fails with: ERROR: cannot insert multiple commands into a prepared statement
DBI::connect("dbi:pg:database=#{dbname};host=#{host};",
user, password) do |dbh|
dbh.do("select 1; select 1;")
end
Other Postgres connectors like Npgsql for .NET and PyGreSQL
for python also support multiple queries. |