Hello.
I'm using Microsoft Sql Server 2008, sqlalchemy 0.7.1.
When I'm trying to create table using metadata.create_all method with
checkfirst=True, an axception is raised.
I set option convert_unicode=True in engine initialization. Here is the
backtrace:
...
File "...", line 32, in _dropTables
checkfirst=True)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\schema.py", line
2442, in drop_all
tables=tables)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\base.py",
line 2178, in _run_visitor
conn._run_visitor(visitorcallable, element, **kwargs)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\base.py",
line 1857, in _run_visitor
**kwargs).traverse_single(element)
File
"C:\Programs\x64\python\lib\site-packages\sqlalchemy\sql\visitors.py", line
86, in traverse_single
return meth(obj, **kw)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\ddl.py",
line 114, in visit_metadata
if self._can_drop_table(t)]
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\ddl.py",
line 137, in _can_drop_table
table.name, schema=table.schema)
File
"C:\Programs\x64\python\lib\site-packages\sqlalchemy\dialects\mssql\base.py",
line 1141, in has_table
c = connection.execute(s)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\base.py",
line 1358, in execute
params)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\base.py",
line 1491, in _execute_clauseelement
compiled_sql, distilled_params
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\base.py",
line 1599, in _execute_context
context)
File "C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\base.py",
line 1592, in _execute_context
context)
File
"C:\Programs\x64\python\lib\site-packages\sqlalchemy\engine\default.py",
line 325, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) ('42000', '[42000]
[Microsoft][ODBC SQL Server Driver][SQL Server]The data types nvarchar and
ntext are incompatible in the equal to operator. (402) (SQLExecDirectW);
[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could
not be prepared. (8180)') u'SELECT [COLUMNS_1].[TABLE_SCHEMA],
[COLUMNS_1].[TABLE_NAME], [COLUMNS_1].[COLUMN_NAME],
[COLUMNS_1].[IS_NULLABLE], [COLUMNS_1].[DATA_TYPE],
[COLUMNS_1].[ORDINAL_POSITION], [COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH],
[COLUMNS_1].[NUMERIC_PRECISION], [COLUMNS_1].[NUMERIC_SCALE],
[COLUMNS_1].[COLUMN_DEFAULT], [COLUMNS_1].[COLLATION_NAME] \nFROM
[INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1] \nWHERE
[COLUMNS_1].[TABLE_NAME] = ? AND [COLUMNS_1].[TABLE_SCHEMA] = ?'
(u'table_name', u'schema_name')
When I execute this query in SSMS, everything is OK:
SELECT [COLUMNS_1].[TABLE_SCHEMA], [COLUMNS_1].[TABLE_NAME],
[COLUMNS_1].[COLUMN_NAME], [COLUMNS_1].[IS_NULLABLE],
[COLUMNS_1].[DATA_TYPE], [COLUMNS_1].[ORDINAL_POSITION],
[COLUMNS_1].[CHARACTER_MAXIMUM_LENGTH], [COLUMNS_1].[NUMERIC_PRECISION],
[COLUMNS_1].[NUMERIC_SCALE], [COLUMNS_1].[COLUMN_DEFAULT],
[COLUMNS_1].[COLLATION_NAME]
FROM [INFORMATION_SCHEMA].[COLUMNS] AS [COLUMNS_1]
WHERE [COLUMNS_1].[TABLE_NAME] = N'table_name' AND
[COLUMNS_1].[TABLE_SCHEMA] = N'schema_name'
Is there a way to solve this problem?
Thank you.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sqlalchemy/-/MtJPM10Rv8gJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.