# inspectdb issue

**URL:** <https://forum.djangoproject.com/t/inspectdb-issue/12761>\
**Category:** Forms & APIs\
**Created:** [March 23, 2022, 5:45am UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761 "2022-03-23T05:45:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boomesshv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/boomesshv/32/7882_2.png) [@Boomesshv](https://forum.djangoproject.com/u/Boomesshv)\
**Post date:** [March 23, 2022, 5:45am UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/1 "2022-03-23T05:45:40Z")

</div>

Hi All,

Good Morning!!! I am new to Django development and I am having the following issue.

My scenario is as follows:

1. I have Microsoft SQL Server with database “timesheet” already (with 10 tables)

2. I have created an environment with Python 3.9.7 and django = 3.2 and also have django-mssql-backend = 2.8.1 and mssql-django = 1.1.2

3. I have created the project and an application first\_app

4. I wanted to get the models in SQL server in [models.py]  
#python manage.py inspectdb  
but this gives the following error

# Unable to inspect table ‘Tbl\_Employee’

# The error was: () missing 1 required positional argument: ‘collation’

# Unable to inspect table ‘Tbl\_EmployeeGroup’

# The error was: () missing 1 required positional argument: ‘collation’

and the same error comes for all other tables.

1. I was first using django 4.0.2 and there too in the inspectDB i got the same error so i created this new environment with django to 3.2 - I am getting the same error in both environments

Could you please help with the following scenario.

Kindly let me know if you require any further info.

Thanks,  
Boomessh V

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [March 23, 2022, 8:00am UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/2 "2022-03-23T08:00:29Z")

</div>

> [@Boomesshv](#):
>
> also have django-mssql-backend = 2.8.1 and mssql-django = 1.1.2

It doesn’t make sense to have both - you can only use one. Check your `DATABASES` setting to which one you’re using - I suspect it’s `mssql-django`, since it’s newer (`mssql-django` is a fork of `django-mssql-backend`, now maintained by microsoft).

* * *

As to the error: Django provides the `inspectdb` command, but it’s up to the database backend to ensure that it works. Therefore this is a bug with django-mssql-backend or mssql-django. Report the bug there, they won’t see it on the forums. I’m sure they will ask for more details regarding the tables in question - perhaps you can show them the SQL `CREATE TABLE` statements.

To make things work for yourself, you can proceed by using `inspectdb` on the tables that it does work for (`inspectdb table1 table2`), then writing models by hand for the two failing tables. `inspectdb` is ultimately just a shortcut for generating some code - the end result is still your code that you’re responsible for, so you shouldn’t be afraid of writing your own.

Hope that helps and good luck!

---

<div class="post-metadata">

**Author:** ![Boomesshv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/boomesshv/32/7882_2.png) [@Boomesshv](https://forum.djangoproject.com/u/Boomesshv)\
**Post date:** [March 23, 2022, 8:23am UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/3 "2022-03-23T08:23:53Z")

</div>

Hi adamchainz,

Thanks for your reply and yes I will try to generate it (models) myself and proceed with the work.

Also, is this what you are mentioning to look at in the settings.py file

DATABASES = {  
‘default’: {  
‘ENGINE’: ‘sql\_server.pyodbc’,  
‘NAME’: ‘TIMESHEET’,  
‘USERNAME’: ‘_’,  
‘PASSWORD’: '_’,  
‘HOST’: ‘\<\>’,  
‘DRIVER’: ‘{ODBC Driver 17 for SQL Server}’,  
}

This is the working connection string.

Thanks,  
Boomessh V

---

<div class="post-metadata">

**Author:** ![adamchainz](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/adamchainz/32/26_2.png) [@adamchainz](https://forum.djangoproject.com/u/adamchainz)\
**Post date:** [March 23, 2022, 8:40am UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/4 "2022-03-23T08:40:20Z")

</div>

From ENGINE, it looks like you’re using django-mssql-backend: [django-mssql-backend · PyPI](https://pypi.org/project/django-mssql-backend/)

If you were using `mssql-django`, your `ENGINE` would be `mssql`: [GitHub - microsoft/mssql-django: The Microsoft SQL Server 3rd Party Backend for Django provides a connectivity layer for Django on SQL Server or Azure SQL DB.](https://github.com/microsoft/mssql-django#installation)

Since mssql-django is the newer package, try that instead. They may have improved inspectdb when they forked the package. Otherwise, report the bug on their GitHub.

---

<div class="post-metadata">

**Author:** ![Boomesshv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/boomesshv/32/7882_2.png) [@Boomesshv](https://forum.djangoproject.com/u/Boomesshv)\
**Post date:** [March 23, 2022, 9:07am UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/5 "2022-03-23T09:07:16Z")

</div>

Hi adamchainz,

Thanks a ton for your reply.  
It finally worked after changing the engine to mssql and I am getting the models.py generated based on my sql database tables.

Is there any site describing the common reference for the ENGINE to the dll mappings (like mssql → mssql-django or pyodbc refers to django-mssql-backend) - kindly let me know.

once again thanks for your reply,  
Boomessh V

---

<div class="post-metadata">

**Author:** ![RaynoKriel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/raynokriel/32/7889_2.png) [@RaynoKriel](https://forum.djangoproject.com/u/RaynoKriel)\
**Post date:** [March 23, 2022, 12:49pm UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/6 "2022-03-23T12:49:38Z")

</div>

Hi @Boomesshv not sure if this will help, but i used this site when i started a few months ago to get an idea of the different Engines Django could use. However not all of them. There are links to Repo’s at the bottom as well, which Adam already referenced as well.

> **[Set up a database for a Django project: PostgreSQL, MySQL, MariaDB, Oracle...](https://www.webforefront.com/django/setupdjangodatabase.html)**
>
> Set up a database for a Django project: PostgreSQL, MySQL, MariaDB Oracle and SQLite, Default Django DATABASES dictionary, Django ENGINE NAME ATOMIC\_REQUESTS AUTOCOMMIT CONN\_MAX\_AGE HOST OPTIONS PASSWORD PORT USER,...

inspectDB can be tricky especially if you have multiple databases configured and if your SCHEMA is not the default one but a custom schema. These might pop up in the future as well :-).

Good luck.

---

<div class="post-metadata">

**Author:** ![Boomesshv](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/boomesshv/32/7882_2.png) [@Boomesshv](https://forum.djangoproject.com/u/Boomesshv)\
**Post date:** [March 23, 2022, 3:29pm UTC](https://forum.djangoproject.com/t/inspectdb-issue/12761/7 "2022-03-23T15:29:57Z")

</div>

Hi RaynoKriel

Thanks - I missed to see that, I checked it now and yes I think I understand it now.

Thanks,  
Boomessh V
