var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: psql transactions in a bash script
I'm trying to build a script which executes several psql queries. I'm using something like:
The problem is, I'd like all those
$ psql -U user -d database -c "query"
psql commands to execute in the same transaction.
Anyone knows how can I do it?
I've been googling around, and found that it may be possible to turn off an autocommit variable using:
but it didn't work
Anyone knows how could this be done?!
Thanks in advance!
Save a single .sql file that has all of your commands.
$ psql -U user -d database < mySQLscript.sql
$ psql -U user -d database -f mySQLscript.sql
Think your right...
I've tried to do it with several psql commands, but the transactions management is very complicated, so it's better to gather all the needed information along the script, save it to a file. And then, in the final execute all queries from file, just as you mentioned.
Thanks a lot for the help
Not complicated, impossible. Each time you fire off a psql command, you are establishing a new connection. You can't have a single transaction across multiple connections.
but the transactions management is very complicated