Re: Alternative to psql -c ? - Mailing list pgsql-general

From Tom Lane
Subject Re: Alternative to psql -c ?
Date
Msg-id 42493.1403805729@sss.pgh.pa.us
Whole thread Raw
In response to Re: Alternative to psql -c ?  (James Le Cuirot <chewi@aura-online.co.uk>)
Responses Re: Alternative to psql -c ?
List pgsql-general
James Le Cuirot <chewi@aura-online.co.uk> writes:
> This got me wondering what Rails uses. I dug into ActiveRecord and
> found that apart from the odd call to PQexec with hardcoded single
> statements, it uses PQsendQuery. The libpq docs state a few of the
> differences but don't mention whether PQsendQuery automatically creates
> a transaction like PQexec does. Please could you clarify this?

PG is not capable of executing queries that are not in transactions,
so yes, PQsendQuery will create a single-statement transaction if you
haven't sent BEGIN.  However, there's a huge difference for the
purposes we're discussing here: PQsendQuery does not allow more than
one SQL command in the string.  So most of this discussion is irrelevant
when you're going through that API.

            regards, tom lane


pgsql-general by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Function Syntax Help
Next
From: Jeff Janes
Date:
Subject: Re: python modul pre-import to avoid importing each time