microsoft / mssql-django

The Microsoft Django backend for SQL Server provides a connectivity layer for Django on SQL Server or Azure SQL DB.
Other
338 stars 112 forks source link

Can't get data from table that is under non-default schema #183

Open Egoart opened 1 year ago

Egoart commented 1 year ago

Hello, I'm a newbie in MS SQL Server and playing with default database AdventureWorks2019. I was able to connect to DB and inspect it with inspectdb Django command. However, I can not query the tables that are under the schemas another than dbo. Here is the error:

'42S02', '[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name "Address". (208) (SQLExecDirectW)'

This table belongs to Person schema. The following approach https://github.com/microsoft/mssql-django/issues/56 (Person.Address) does not work for me as well and results in the same error. Do you have any clues how to solve the problem? I'm using MS SQL Server 2019 Express (windows authentication), Django 4.0.7, mssql-django 1.1.3

Thank you

mShan0 commented 1 year ago

Hi @Egoart, what specifically are you trying to do with different schemas? Are you trying to inspect different schemas via inspectdb?

Egoart commented 1 year ago

Hi @Egoart, what specifically are you trying to do with different schemas? Are you trying to inspect different schemas via inspectdb?

inspectdb is working well for me. I can inspect tables in different schemas passing the table name as an additional argument. However, when I'm trying to retrieve objects from a table using Django ORM, I've got that error in case of tables that are not in dbo schema.

zHenriqueSI commented 1 year ago

I have the same problem @Egoart . Did you find a way to resolve?