google-code-export / django-pyodbc

Automatically exported from code.google.com/p/django-pyodbc
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

View Introspection #56

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Change introspection.py's table select from this:
cursor.execute("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE
TABLE_TYPE = 'BASE TABLE'")
to this:
cursor.execute("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE
TABLE_TYPE = 'BASE TABLE' OR TABLE_TYPE = 'VIEW'")

This allows for introspection of views as well as tables. One downside is
that it pulls in system views too. In my case it pulls down a few hundred
sync tables too. However I'm willing to manually filter that out to get the
introspection done on the other views. 

Original issue reported on code.google.com by gpm...@gmail.com on 17 Jun 2009 at 12:27

GoogleCodeExporter commented 9 years ago
Here's what django-mssql uses, which I don't think pulls in system views:
http://code.google.com/p/django-mssql/source/browse/trunk/source/sqlserver_ado/i
ntrospection.py#7

Original comment by fla...@gmail.com on 24 Jun 2009 at 4:35

GoogleCodeExporter commented 9 years ago
It's not necessarily useful to everyone. But to those who need it, it's 
awesome. 

Original comment by gpm...@gmail.com on 24 Jun 2009 at 6:03

GoogleCodeExporter commented 9 years ago
We've been using this for quite some time. It excludes the system views:

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE 
TABLE' UNION SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE 
LEFT(TABLE_NAME, 3) <> 'sys'

Original comment by rlaa...@gmail.com on 19 Oct 2010 at 3:56