Re: [cx-oracle-users] cx_Oracle4.3.1: - describe table query is not working!!!
Brought to you by:
atuining
From: Amaury F. d'A. <ama...@gm...> - 2007-05-09 10:10:08
|
Hello, Piyush Chechani wrote: > > Hey Richard, > > Thanks a lot man for quotin g that query, > But I was asking specifically for that particular query, that 'describe > <tabl-name>' runs when we execute this in SQL*Plus, but it doesn't from > cx_Oracle interface. Why so. SQL*Plus has features and commands that are not SQL queries, but are useful in a command-line interface to the database. For example, "connect", "spool", "set linesize" are not SQL queries. "describe" is such a command. In cx_Oracle, you can implement the 'describe' command like this: def describe(connection, tablename): cur =connection.cursor() cur.execute('select * from %s where 1=0' % tablename) for desc in cur.description: column_name = desc[0] nullable = desc[6] data_type = desc[1].__name__ data_length = desc[3] print column_name, nullable, data_type, data_length -- Amaury Forgeot d'Arc |