Python Forum

Full Version: Python - Netezza cursor function help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello friends,

I'm trying to fetch all view defintions defined in a database using Python

query="SELECT DEFINITION FROM DATABSE1.._V_VIEW WHERE database='DATABASE1' and VIEWNAME in ('VIEW1','VIEW2')"
cur.execute(query)
defintion=cur.fetchall()
print (defintion)

I'm getting below result :
[('Not a view', ), ('SELECT * FROM TABLE1)]

If I use the same query in database I get two SQL queries. Do not know why Python returns 'Not a view' result for some views.
The Database is Netezza.

Value in DEFINITION column is very huge 4000-5000 characters, it's the view definition.

Has anyone faced similar issue before? Look forward to hearing your responses :)

Thanks,
Leo
What type of dbms?
DB is Netezza
I'm using pyodbc to connect
I'm not familiar with that dbms, but I'm sure there must be an admin manager available.
If so, you can use it to go in and look at the system table schema to find out exactly what's
in it.
I use postgreSQL, and sqlite, and in the past have used Oracle extensively, also Informix, Sybase,
and dbase (Alpha actually which was a dbase clone). All had the capability of viwing the schema.

I found this: http://dwgeek.com/netezza-database-schem...hema.html/

If you use this, it should make sense as to why you can't find your views.
Thanks Larz. I was able to resolve the issue. It was some kind permission issue, the schema that I was using did not have access to view the definition of the view under scope.