Re: [sqlalchemy] Cannot insert strings with a length greater than 2000 into columns with a datatype of Text, VARCHAR, or NVARCHAR using MS SQL Server 2017 and 2019

2020-10-16 Thread Mike Bayer
On Fri, Oct 16, 2020, at 10:25 AM, Simon King wrote: > Yep, I misunderstood what setinputsizes was doing. I thought it told > pyodbc how it should handle a particular datatype, that would be great if it worked that way :) however alas... > > > rather than telling > it how to handle the

Re: [sqlalchemy] Cannot insert strings with a length greater than 2000 into columns with a datatype of Text, VARCHAR, or NVARCHAR using MS SQL Server 2017 and 2019

2020-10-16 Thread Simon King
Yep, I misunderstood what setinputsizes was doing. I thought it told pyodbc how it should handle a particular datatype, rather than telling it how to handle the set of parameters it is about receive in the next execute() call... Sorry for adding to the confusion, Simon On Fri, Oct 16, 2020 at

Re: [sqlalchemy] postgresql JSON(B) dialect: update value of a specific key in a JSON object

2020-10-16 Thread Mike Bayer
from sqlalchemy import Column from sqlalchemy import Integer from sqlalchemy import update from sqlalchemy.dialects import postgresql from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base):

Re: [sqlalchemy] Text subquery column names in the results

2020-10-16 Thread Mike Bayer
On Fri, Oct 16, 2020, at 2:30 AM, Kotofos online wrote: > I'm working on raw SQL feature, and it has to support distinct and sort. > Instead of parsing and modifying user query, I'm wrapping it as subquery and > then do distinct and sort. > > ``` > user_query = 'select "FirstName", from

Re: [sqlalchemy] Cannot insert strings with a length greater than 2000 into columns with a datatype of Text, VARCHAR, or NVARCHAR using MS SQL Server 2017 and 2019

2020-10-16 Thread Mike Bayer
On Fri, Oct 16, 2020, at 3:53 AM, Nicolas Lykke Iversen wrote: > Is it really necessary to use your very-subtle vendored version of the > set_input_sizes() hook? Why use it compared to Simon King's simple version? yes, because cursor.setinputsizes() must be passed an entry for every bound

[sqlalchemy] postgresql JSON(B) dialect: update value of a specific key in a JSON object

2020-10-16 Thread Massimiliano della Rovere
Greetings, how should I write the .values() section of a CORE update() statement to render the following postgres syntax? The data column is a JSON(B) and contains a dict object. UPDATE settings SET data = data || '{"key": "value"}' WHERE key = 'my_param'; Thanks, Massimiliano -- SQLAlchemy -

Re: [sqlalchemy] Cannot insert strings with a length greater than 2000 into columns with a datatype of Text, VARCHAR, or NVARCHAR using MS SQL Server 2017 and 2019

2020-10-16 Thread Nicolas Lykke Iversen
Thank you, Mike. pyODBC has the following to say about the issue: *SQLAlchemy. pyODBC is generic and does not know about special handling of varchar(max), whereas SQLAlchemy appears to have code for specific database types. It needs to call setinputsizes as you described, when the length is

Re: [sqlalchemy] Text subquery column names in the results

2020-10-16 Thread Kotofos online
I'm working on raw SQL feature, and it has to support distinct and sort. Instead of parsing and modifying user query, I'm wrapping it as subquery and then do distinct and sort. ``` user_query = 'select "FirstName", from "Customer"' stmt = text(user_query) stmt =