djangodjango-pyodbcdjango-pyodbc-azure

django-pyodbc-azure - How to use schemas


I'm using django-pyodbc-azure (https://github.com/michiya/django-pyodbc-azure) and everything is working fine. However, when I migrate the models, a new schema called 'dbo' is created on the SQL Server database. I want to use an already existing 'sp' schema, is there any way to set the working schema?

Thanks in advance.


Solution

  • IIRC, you need to change the default schema for the user your are connecting as. If you're using a SQL Auth user called django_user:

    ALTER USER django_user WITH DEFAULT_SCHEMA = [sp]
    

    Good luck.