I have stored procedure which I call using SQLAlchemy that concatenates a column in MSSQL. When I run the same stored procedure through MSSQL, it behaves correctly but running through SQLAlchemy it duplicates the value.
stored procedure:
UPDATE table
SET LocationId = @LocationId,
BoxesDelivered = @BoxesDelivered,
TrackingNo = @BatchNumber,
From = CONCAT(From, CHAR(13), CHAR(10), @Info)
WHERE JobCode = @JobCode;
Here is the SQLAlchemy code:
update_location = "EXEC UpdateCallerLocation "\
"@JobCode=:job_code, "\
"@LocationId=:new_location_id, "\
"@BoxesDelivered=:boxes_delivered, "\
"@BatchNumber=:batch_number, "\
"@Info=:batch_info"
Running this via SQLAlchemy and I get the following:
order delivered on: 01-11-2023
order delivered on: 11-11-2023
order delivered on: 11-11-2023
the last 2 entries are duplicated executing the stored procedure once through SQLAlchemy.
Ensure you are not creating a new session unintentionally for each call.