Re: [cx-oracle-users] cx_Oracle4.3.1: - describe table query is not working!!!
Brought to you by:
atuining
From: Piyush C. <piy...@tc...> - 2007-05-09 09:20:52
|
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. Thanks for responding. cPiyush. cx-...@li... wrote on 05/09/2007 02:37:47 PM: > Piyush Chechani wrote: > > Hi all... > > > > Just have a look on the code below... > > > > (We have 'sample database with one of the table 'tab1' & user 'demo') > > > > #We are trying to fetch all the columns from the table specified & their > > type. > > #This is done by using 'describe <table-name>' sql query in Oracle. > > > > import cx_Oracle > > > > connection = cx_Oracle.Connection("demo/demo@sample") > > cursor = connection.cursor() > > cursor.execute("describe tab1") > > for row in cursor.description: > > print "Column Name is: ",row[0] > > print "Column Type is: ", row[1] > > print "------------------------------------------------" > > > > #But this is giving error that is: - cx_Oracle.DatabaseError: ORA-00900: > > invalid SQL statement > > #I got some other method to implement this, but that is a bit lengthy. > > (can put that also if required) > > #My quetion is that does cx_Oracle supports 'describe <table-name>' query > > or not??? > > I don't think it does (it's not really a query). You can get the > same information using a query of the data dictionary. For example > > select table_name from user_tables; -- Get a list of tables > select column_name, data_type from all_tab_columns where table_name = > 'RESELLER'; -- Get the names and types of the table RESELLER. > > Cheers =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you |