pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
viewing the description of tables from python DB-API
5+ messages / 5 participants
[nested] [flat]

* viewing the description of tables from python DB-API
@ 2006-08-01 22:30 Daniel Joo <djoo@vistagen-inc.com>
  2006-08-01 23:00 ` Re: viewing the description of tables from python DB-API Alvaro Herrera <alvherre@commandprompt.com>
  2006-08-01 23:14 ` Re: viewing the description of tables from python DB-API Rodrigo De Leon <rdeleonp@gmail.com>
  2006-08-07 19:20 ` Re: viewing the description of tables from python DB-API George Young <gry@ll.mit.edu>
  0 siblings, 3 replies; 5+ messages in thread

From: Daniel Joo @ 2006-08-01 22:30 UTC (permalink / raw)
  To: pgsql-sql

Hi all,

 

Is there a way to view the list of all tables from python (or any other
languages for that matter) DB-API?  What I'm looking for is a command
similar to the meta-command '\d' that works with the psql client.  

 

Thanks very much!

 

Dan

 

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: viewing the description of tables from python DB-API
  2006-08-01 22:30 viewing the description of tables from python DB-API Daniel Joo <djoo@vistagen-inc.com>
@ 2006-08-01 23:00 ` Alvaro Herrera <alvherre@commandprompt.com>
  2 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2006-08-01 23:00 UTC (permalink / raw)
  To: Daniel Joo <djoo@vistagen-inc.com>; +Cc: pgsql-sql

Daniel Joo wrote:

> Is there a way to view the list of all tables from python (or any other
> languages for that matter) DB-API?  What I'm looking for is a command
> similar to the meta-command '\d' that works with the psql client.  

Try \d under psql -E sometime.  It'll give you the query it uses.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: viewing the description of tables from python DB-API
  2006-08-01 22:30 viewing the description of tables from python DB-API Daniel Joo <djoo@vistagen-inc.com>
@ 2006-08-01 23:14 ` Rodrigo De Leon <rdeleonp@gmail.com>
  2006-08-02 16:22   ` Re: viewing the description of tables from python DB-API Scott Marlowe <smarlowe@g2switchworks.com>
  2 siblings, 1 reply; 5+ messages in thread

From: Rodrigo De Leon @ 2006-08-01 23:14 UTC (permalink / raw)
  To: pgsql-sql

On 8/1/06, Daniel Joo <djoo@vistagen-inc.com> wrote:
> Hi all,
>
>
>
> Is there a way to view the list of all tables from python (or any other
> languages for that matter) DB-API?  What I'm looking for is a command
> similar to the meta-command '\d' that works with the psql client.
>
>
>
> Thanks very much!
>
>
>
> Dan

There's also the INFORMATION_SCHEMA:

http://www.postgresql.org/docs/8.1/static/information-schema.html

Regards,

Rodrigo



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: viewing the description of tables from python DB-API
  2006-08-01 22:30 viewing the description of tables from python DB-API Daniel Joo <djoo@vistagen-inc.com>
  2006-08-01 23:14 ` Re: viewing the description of tables from python DB-API Rodrigo De Leon <rdeleonp@gmail.com>
@ 2006-08-02 16:22   ` Scott Marlowe <smarlowe@g2switchworks.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Scott Marlowe @ 2006-08-02 16:22 UTC (permalink / raw)
  To: Rodrigo De Leon <rdeleonp@gmail.com>; +Cc: pgsql-sql

On Tue, 2006-08-01 at 18:14, Rodrigo De Leon wrote:
> On 8/1/06, Daniel Joo <djoo@vistagen-inc.com> wrote:
> > Hi all,
> >
> >
> >
> > Is there a way to view the list of all tables from python (or any other
> > languages for that matter) DB-API?  What I'm looking for is a command
> > similar to the meta-command '\d' that works with the psql client.
> >
> >
> >
> > Thanks very much!
> >
> >
> >
> > Dan
> 
> There's also the INFORMATION_SCHEMA:
> 
> http://www.postgresql.org/docs/8.1/static/information-schema.html

Quick note.  The INFORMATION_SCHEMA should stay pretty static from one
pgsql version to the next, while the queries that psql -E shows will
likely change from one version to another.



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: viewing the description of tables from python DB-API
  2006-08-01 22:30 viewing the description of tables from python DB-API Daniel Joo <djoo@vistagen-inc.com>
@ 2006-08-07 19:20 ` George Young <gry@ll.mit.edu>
  2 siblings, 0 replies; 5+ messages in thread

From: George Young @ 2006-08-07 19:20 UTC (permalink / raw)
  To: pgsql-sql

On Tue, 1 Aug 2006 15:30:48 -0700
"Daniel Joo" <djoo@vistagen-inc.com> wrote:

> Is there a way to view the list of all tables from python (or any other
> languages for that matter) DB-API?  What I'm looking for is a command
> similar to the meta-command '\d' that works with the psql client.  

The cursor object has a "description" data member.  
Look at the DB-API spec:  http://www.python.org/dev/peps/pep-0249/
under "Cursor Objects".

Python 2.3.3 (#1, Jan  3 2004, 07:17:11) 
[GCC 3.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pgdb
>>> db=pgdb.connect(database='pigrestore', host='ivy')
>>> cur=db.cursor()
>>> cur.execute('select * from machine')
>>> print cur.description
[('machine_name', 'text', -1, -1, None, None, None), ('machine_id', 'int2', -1, 2, None, None, None), ('area', 'text', -1, -1, None, None, None), ('text', 'text', -1, -1, None, None, None)]
>>> 

-- 
"Are the gods not just?"  "Oh no, child.
What would become of us if they were?" (C.S. Lewis)



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2006-08-07 19:20 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01 22:30 viewing the description of tables from python DB-API Daniel Joo <djoo@vistagen-inc.com>
2006-08-01 23:00 ` Alvaro Herrera <alvherre@commandprompt.com>
2006-08-01 23:14 ` Rodrigo De Leon <rdeleonp@gmail.com>
2006-08-02 16:22   ` Scott Marlowe <smarlowe@g2switchworks.com>
2006-08-07 19:20 ` George Young <gry@ll.mit.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox