From 60f627cbd0d769e65353e720548efac9d8ab95d9 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Thu, 13 Feb 2020 12:14:42 -0700 Subject: Replace engine.execute w/ context manager (step1) First (baby) step at replacing engine.execute calls in test code with the new preferred way of executing. MSSQL was targeted because it was the easiest for me to test locally. Change-Id: Id2e02f0e39007cbfd28ca6a535115f53c6407015 --- lib/sqlalchemy/dialects/mssql/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/dialects') diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index f900441a2..01e07729d 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -182,7 +182,8 @@ execution. Given this example:: Column('x', Integer)) m.create_all(engine) - engine.execute(t.insert(), {'id': 1, 'x':1}, {'id':2, 'x':2}) + with engine.begin() as conn: + conn.execute(t.insert(), {'id': 1, 'x':1}, {'id':2, 'x':2}) The above column will be created with IDENTITY, however the INSERT statement we emit is specifying explicit values. In the echo output we can see -- cgit v1.2.1