Skip to content
Advertisement

Pythonic way to optimize SQL VIEW count to extract information schema metadata from Snowflake

I have 12 VIEW tables in Snowflake and I would like to extract TABLE_NAME,CREATED,LAST_ALTERED from Snowflakes INFORMATION Schema for View tables, and also want to get row count for each 12 VIEW tables, along with metadata for Base table mentioned in below code.I was wondering if there is way get row count using below code for 12 VIEW tables or there is any better approach for this task i.e. getting TABLE_NAME,CREATED,LAST_CREATED metadata for Base Table and VIEW table in Snowflake ?

Let’s say my first 4 VIEW table names are “V_ACCOUNT”,”V_ADDRESS”,”V_COUNTRY”,”V_ORDER”

Below is my code so far.

Thanks in advance for your time and efforts!

Python Code:

Advertisement

Answer

If you are looking for how to dynamically create a view in Python, then please take a look at Barmar’s answer on my other question here. This will give you a hint of what needs to be done for dynamic view creation. Thanks, Barmar for help!

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement