Skip site navigation (1) Skip section navigation (2)

is it possibile get the psql prompt output?

From: Ottavio Campana <ottavio(at)campana(dot)vi(dot)it>
To: psycopg(at)postgresql(dot)org
Subject: is it possibile get the psql prompt output?
Date: 2012-05-16 07:06:56
Message-ID: 4FB35210.9000009@campana.vi.it (view raw or flat)
Thread:
Lists: psycopg
I am writing a small python script and I'd like to get the output I 
would get as if I executed the commands from psql. Let's make an 
example, suppose you have a small table such as

create table xxx_test (
         id serial,
         description text);

and that you perform this command in psql

mydb=# INSERT INTO xxx_test values (default, 'ciao');
INSERT 0 1
mydb=#

In python I do

cursor = connection.cursor ()
cursor.execute (command)
connection.commit ()

with command being the insert command. Now the question is: is there a 
way to get the "INSERT 01" back?

Thank you,

Ottavio

Responses

psycopg by date

Next:From: Federico Di GregorioDate: 2012-05-16 07:24:18
Subject: Re: is it possibile get the psql prompt output?
Previous:From: Kryklia AlexDate: 2012-05-15 16:59:23
Subject: Question aboud #80 - itersize in cursor dic

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group