Python Forum
Python - Netezza cursor function help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python - Netezza cursor function help (/thread-7346.html)



Python - Netezza cursor function help - leojosefm - Jan-05-2018

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


RE: Python - Netezza cursor function help - Larz60+ - Jan-05-2018

What type of dbms?


RE: Python - Netezza cursor function help - leojosefm - Jan-05-2018

DB is Netezza
I'm using pyodbc to connect


RE: Python - Netezza cursor function help - Larz60+ - Jan-05-2018

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-schema-create-alter-drop-set-schema.html/

If you use this, it should make sense as to why you can't find your views.


RE: Python - Netezza cursor function help - leojosefm - Jan-08-2018

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.