Prepared transactions didn't work with redshift ( undefined method `[]' for nil:NilClass). I am guessing this is because redshift doesn't support prepared transactions. So I guess my only option is the Sequel.transactions method.
Is there a way to turn off autocommit on the individual calls? On Tue, Mar 25, 2014 at 4:22 PM, Tim Uckun <[email protected]> wrote: > >> You shouldn't do that. To correctly handle transactions in distributed >> databases, you should use prepared transactions/two phase commit, which >> Sequel supports on some databases. See >> http://sequel.jeremyevans.net/rdoc/files/doc/transactions_rdoc.html >> >> > > One database is redshift the other is postgres so I'll try this and see > what happens. > > > >> If you can't use prepared transactions, you can use Sequel.transaction: >> >> Sequel.transaction([db1, db2]) do >> r1 = db1[sql].returning.all >> r2 = db2[sql].returning.all >> raise Sequel::Rollback unless (do some checking here) >> end >> >> Note that Sequel.transaction uses regular transactions, so if the first >> database commits and the second database fails to commit (due to deferred >> constraint violations, for example), you have some serious problems. >> >> > This would mess me up for sure. It has to be all or nothing on both > databases. > > > > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
