On 09/28/2016 02:32 AM, [email protected] wrote:
Usual apologies for newbie question...
I'm trying to use SQLAlchemy to insert data into a MSSQL DB with columns
of type VARBINARY(MAX). The only way I could find to avoid the error message
Implicit conversion from data type varchar to varbinary(max) is not
allowed. Use the CONVERT function to run this query.
wais to wrap the bound column in CONVERT(VARBINARY(MAX), ...). This
however creates problems when I want to use the same code on other
database types. I guess I could work around this issue by manually
checking the database dialect, but since one purpose of SQLAlchemy
appears to be to help write DB agnostic code, I would hope that this
problem could be solved in a cleaner way.
Many thanks for any suggestions.
if you are getting that error on INSERT it sounds like there are driver
issues involved (e.g. pymssql, pyodbc). For an INSERT you should not
get that error; using the VARBINARY SQLAlchemy type, SQLAlchemy calls
upon a construct provided by your DBAPI (e.g., the driver) called
Binary(). This is a wrapper that is intended to signal to the driver
that this value is not a character string, it's bytes. Internally the
driver should be doing this step.
For here we'd look to see what driver you're using, if changing drivers
resolves, and as always a small and self-contained reproducing test
case. For a driver issue I'd then look to convert the test case to be
using the DB driver alone, then we send a bug report to that driver.
--
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 [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.