You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: this might be a really stupid question, I actually know very little about schemas and mssql.
I am running python manage.py inspectdb on a mssql database that contains multiple schemas.
These are a way of separating topics inside the db (I think?).
E.g. there might be a schema called users that contains the tables users.User, users.Post, users.Friendships and a second schema called games that contains other tables.
When I run inspectdb the output is empty because there are no tables in the main scheme dbo.
sql='SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = SCHEMA_NAME()'
to
sql="SELECT TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES;"
and now all tables are created. Only the schemes names are not displayed correctly in db_table. It says 'User' instead of 'users.User', but that's fixed fast.
So my question: Why did you choose to only inspect tables in dbo? Did I miss something in the settings? Is creating multiple schemes something very unusual?
The text was updated successfully, but these errors were encountered:
A small note: it inspects whichever schema is set as the user's default schema (which is normally dbo). I have a db with two schemas that I wanted to generate models for, so I just switched my test user's default schema to each of them before running inspectdb.
Django does not natively support schemas, which is really too bad. db_table = '[schema].[tablename]' works pretty well, but will run into trouble if you ever want Django to manage your table.
Disclaimer: this might be a really stupid question, I actually know very little about schemas and mssql.
I am running
python manage.py inspectdb
on a mssql database that contains multiple schemas.These are a way of separating topics inside the db (I think?).
E.g. there might be a schema called
users
that contains the tablesusers.User
,users.Post
,users.Friendships
and a second schema calledgames
that contains other tables.When I run
inspectdb
the output is empty because there are no tables in the main schemedbo
.I changed
django-mssql-backend/sql_server/pyodbc/introspection.py
Line 65 in 79e421a
and now all tables are created. Only the schemes names are not displayed correctly in
db_table
. It says 'User' instead of 'users.User', but that's fixed fast.So my question: Why did you choose to only inspect tables in
dbo
? Did I miss something in the settings? Is creating multiple schemes something very unusual?The text was updated successfully, but these errors were encountered: