michiya / django-pyodbc-azure

Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
https://pypi.python.org/pypi/django-pyodbc-azure
BSD 3-Clause "New" or "Revised" License
323 stars 140 forks source link

InspectDB cannot make SSISDB tables imports #171

Open angelqb17 opened 6 years ago

angelqb17 commented 6 years ago

I am using the latest 2.x version of django, i am using a SQL 2016 Server from Microsoft and using the django pyodbc azure for connecting to the database, my problem is that i want to generate the models for the SSISDB database that is created when you generate a catalog in MSSQL but when i run the inspectdb doesnt generate the models, instead if i use one of the databases generated by me in the same server it works. What im i missing? captura captura1

angelqb17 commented 6 years ago

some one could help me with this isssue?

michiya commented 5 years ago

I guess this is a similar issue to #156. inspectdb now takes account of database schemas for tables as described in #133. To generate models for the tables created outside your Django project, you will need to make sure that:

angelqb17 commented 5 years ago

@michiya i dont think is that because i change the connector engine to django-pyodbc and with that connect i could generate the models.

jdnrg commented 5 years ago

change this line to sql = 'SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = \'dbo\''

https://github.com/jdnrg/django-pyodbc-azure/commit/6fdeae9f85d16f7438ac835fc0ac114bcfeb0a0a

MikeSandford commented 5 years ago

I'm having a similar problem as described here; I end up seeing only one table "Sysdiagrams" despite seeing a great many more using the same credentials with raw pyodbc and querying sys.tables (including the sysdiagrams table).

I tried manually changing what @jdnrg suggested and I'm getting the same results. I've looked at the raw table dump I'm seeing from pyodbc and there's very little to distinguish them from one another that I can tell. I tried opening the database with SQL Server Management Studio but something's wrong there so I can't dig in much further; I suspect that I have the same problem as listed above: wrong default schema.

jdnrg commented 5 years ago

If you want to see all the tables why not remove the constraint?

Sent from my T-Mobile 4G LTE Device

-------- Original message -------- From: Mike Sandford notifications@github.com Date: 5/28/19 19:44 (GMT-05:00) To: michiya/django-pyodbc-azure django-pyodbc-azure@noreply.github.com Cc: "DuPont, James" James.DuPont@nrg.com, Mention mention@noreply.github.com Subject: Re: [michiya/django-pyodbc-azure] InspectDB cannot make SSISDB tables imports (#171)

I'm having a similar problem as described here; I end up seeing only one table "Sysdiagrams" despite seeing a great many more using the same credentials with raw pyodbc and querying sys.tables (including the sysdiagrams table).

I tried manually changing what @jdnrghttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jdnrg&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=PvytTvYGcnpluClXEAAtVFbPLo57ecMTVNfu3kUKwJI&s=rTyOeEkDqlXvYz5TO8ZvsV-ZX9Z2C5dj8pRb2rEXaj8&e= suggested and I'm getting the same results. I've looked at the raw table dump I'm seeing from pyodbc and there's very little to distinguish them from one another that I can tell. I tried opening the database with SQL Server Management Studio but something's wrong there so I can't dig in much further; I suspect that I have the same problem as listed above: wrong default schema.

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_michiya_django-2Dpyodbc-2Dazure_issues_171-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAKCCNSLGRGICQ4OWRLQP4STPXW7VHA5CNFSM4FHBDEGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWNYAIY-23issuecomment-2D496730147&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=PvytTvYGcnpluClXEAAtVFbPLo57ecMTVNfu3kUKwJI&s=Kjc1UbCwDfxn3XkQUAP8c8x9vCcUV5DodNQA7NTUKm0&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AKCCNSKRABP3BJIATILEUVDPXW7VHANCNFSM4FHBDEGA&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=PvytTvYGcnpluClXEAAtVFbPLo57ecMTVNfu3kUKwJI&s=2TTGr1-ds_mMz5dxi4dzyOF2bHiOXU9CEtR1WYJj1tY&e=.

MikeSandford commented 5 years ago

Hey @jdnrg I did that, removing the entire WHERE clause and running this query:

 sql = 'SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES'

and when I did so I got 64 models (and tables) instead of one. It worked beautifully! Thanks for the suggestion. It's been so long since I've used SQL Server meaningfully and seeing the comments above "you have to own the tables" I didn't think it would work but I was pleasantly surprised.

@michiya thanks for making this for us! It's super helpful, especially when you work in a large org.

jdnrg commented 5 years ago

Love open source.

Sent from my T-Mobile 4G LTE Device

-------- Original message -------- From: Mike Sandford notifications@github.com Date: 5/29/19 07:42 (GMT-05:00) To: michiya/django-pyodbc-azure django-pyodbc-azure@noreply.github.com Cc: "DuPont, James" James.DuPont@nrg.com, Mention mention@noreply.github.com Subject: Re: [michiya/django-pyodbc-azure] InspectDB cannot make SSISDB tables imports (#171)

Hey @jdnrghttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jdnrg&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=LUk1IOM4XYb4ape43FSZHPpmHcTPJ1Qk04ttT7KvUqM&s=57S7GsC306NaYvT50RDeV-qZAOQSizbX7ZLjSRIVi3g&e= I did that, removing the entire WHERE clause and running this query:

sql = 'SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES'

and when I did so I got 64 models (and tables) instead of one. It worked beautifully! Thanks for the suggestion. It's been so long since I've used SQL Server meaningfully and seeing the comments above "you have to own the tables" I didn't think it would work but I was pleasantly surprised.

@michiyahttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_michiya&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=LUk1IOM4XYb4ape43FSZHPpmHcTPJ1Qk04ttT7KvUqM&s=K4kO_TOFU57q-xFld_nEYw1m-e9nwNyrn59gI7OdcV0&e= thanks for making this for us! It's super helpful, especially when you work in a large org.

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_michiya_django-2Dpyodbc-2Dazure_issues_171-3Femail-5Fsource-3Dnotifications-26email-5Ftoken-3DAKCCNSO3AP5XSU4HOLOQ5CTPXZT2DA5CNFSM4FHBDEGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWPBYJQ-23issuecomment-2D496901158&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=LUk1IOM4XYb4ape43FSZHPpmHcTPJ1Qk04ttT7KvUqM&s=ggekKtw_NjdYLNca-lIfqIdXe1v5ueg9IrQjX6TaNak&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AKCCNSJAM4EF6BC5OWEMJALPXZT2DANCNFSM4FHBDEGA&d=DwMCaQ&c=1pFHxiY6xZ5rRU3-imLzRA&r=XZP5WKaRp3h7IuIu42K58u1fY6y-96hUdKvELjAkKtA&m=LUk1IOM4XYb4ape43FSZHPpmHcTPJ1Qk04ttT7KvUqM&s=QDLYwjj9nxZwn2UwLTFP4L1WTODmNDW_4K-WdFOi2wY&e=.