Default schema_name not "dbo" for MS SQL 2005

Issue #1549 resolved
Former user created an issue

We recently upgraded our Microsoft SQL Server from 2000 to 2005 and discovered that reflected tables no longer work. In looking at the raw SQL that SqlAlchemy is sending, we noticed that it is overriding the schema_name from "dbo" to the username we pass in our create_engine statement.

I have attached the code we use to create the error, although I removed our credential info. I have also attached the engine's echoed SQL statements and the traceback that is produced when we run the code.

We are running this from a Windows XP SP3 box with Python 2.5.2, pyodbc 2.1.6, SqlAlchemy 0.5.6. I hope this is enough information.

Comments (7)

  1. Mike Bayer repo owner
    • removed milestone

    table reflection uses the default schema name as provided by the database if not provided otherwise specific to a Table. That's why you see a query looking for "default_schema_name" from "sys.database_principals". If your tables are in a schema other than the default, you need to specify it using the "schema" argument sent to Table(). The "schema_name='dbo'" argument I believe is just to support older versions of MSSQL that don't support this concept.

  2. Former user Account Deleted

    I tried forcing the schema_name to "dbo" to in case that was the issue, but it continues to exhibit the issue. I also tried autoloading in the un-declarative way, but the same traceback appears then too.

  3. Log in to comment