- attached test.py
Default schema_name not "dbo" for MS SQL 2005
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)
-
Account Deleted -
Account Deleted - attached Sa-echo.txt
SQL statements from echo
-
Account Deleted - attached traceback.txt
Python traceback
-
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. -
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.
-
repo owner one more time. *schema_name is ignored*. use the "schema" argument on your
Table
object. example: http://www.sqlalchemy.org/docs/05/metadata.html#specifying-the-schema-name -
repo owner - changed status to invalid
- Log in to comment
Python test script