mssql+pyodbc://[...]/[...]?trusted_connection=yes&charset=utf8&deprecate_large_types=True A Which is given to the SQLAlchemy class instance db after the initialization of the app with:
db.init_app(app) The offending model:
class Annotations(db.Model):
id = db.Column(db.Integer, primary_key=True)
creation_date = db.Column(db.DateTime, default=datetime.datetime.now)
created_by = db.Column(db.String, nullable=False)
annotation = db.Column(sqlalchemy.Unicode, nullable=False)
annotation_type_id = db.Column(db.Integer, db.ForeignKey('AnnotationTypes.id'))
The query:
db.session.query(Annotations.annotation).all()I've replaced the original column type db.String with sqlalchemy.Unicode on the field that throws the error as per an earlier question on this list but it hasn't resolved the problem.
Could someone offer any pointers?
Thanks,
db.session.query(cast(Annotations.annotation, sa.Unicode).filter(cast(AnnotatedData.annotated_string, sa.String) == cast(annotation_instance, sa.String)).all()
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
File "C:\Python27\lib\site-packages\sqlalchemy\orm\query.py", line 2320, in allreturn list(self)File "C:\Python27\lib\site-packages\sqlalchemy\orm\query.py", line 2438, in __iter__return self._execute_and_instances(context)File "C:\Python27\lib\site-packages\sqlalchemy\orm\query.py", line 2453, in _execute_and_instancesresult = conn.execute(querycontext.statement, self._params)File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 729, in executereturn meth(self, multiparams, params)File "C:\Python27\lib\site-packages\sqlalchemy\sql\elements.py", line 322, in _execute_on_connectionreturn connection._execute_clauseelement(self, multiparams, params)File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 826, in _execute_clauseelementcompiled_sql, distilled_paramsFile "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 958, in _execute_contextcontext)File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 1159, in _handle_dbapi_exceptionexc_infoFile "C:\Python27\lib\site-packages\sqlalchemy\util\compat.py", line 199, in raise_from_causereraise(type(exception), exception, tb=exc_tb)File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 951, in _execute_contextcontext)File "C:\Python27\lib\site-packages\sqlalchemy\engine\default.py", line 436, in do_executecursor.execute(statement, parameters)ProgrammingError: (ProgrammingError) ('42000', '[42000] [Microsoft][ODBC SQL Server Driver][SQL Server]The data types varchar(max) 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)') [....]
[Script ... ] line 450, in getAnnotationTypes.tag_or_inline == self.tag_or_inline).all()File "C:\Python27\lib\site-packages\sqlalchemy\orm\query.py", line 2320, in allreturn list(self)File "C:\Python27\lib\site-packages\sqlalchemy\orm\loading.py", line 76, in instanceslabels) for row in fetch]File "C:\Python27\lib\site-packages\sqlalchemy\orm\query.py", line 3523, in procreturn row[column]UnicodeDecodeError: 'utf8' codec can't decode byte 0x93 in position 506: invalid start byte
. . . ?trusted_connection=yes&charset=utf8&deprecate_large_types=True&convert_unicode=True
> <mailto:sqlalchemy+unsub...@googlegroups.com>.