You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After get connection from connection pool, application run below code to make two database insert in a transaction.
The problem is when sql_2 execute fails, the database connection is released.
Would you please help suggest where is wrong.
with conn:
with conn.cursor() as cur:
sql_1= "INSERT INTO T1 (V1, V2) values(%s, %s)"
cur.execute(sql_1, ('Value1', 'Value2'))
sql_2= "INSERT INTO T2 (V3, V4) values(%s, %s)"
cur.execute(sql_2, ('Value3', 'Value4'))
conn.commit()
The text was updated successfully, but these errors were encountered:
Hi,
After get connection from connection pool, application run below code to make two database insert in a transaction.
The problem is when sql_2 execute fails, the database connection is released.
Would you please help suggest where is wrong.
with conn:
with conn.cursor() as cur:
sql_1= "INSERT INTO
T1
(V1
,V2
) values(%s, %s)"cur.execute(sql_1, ('Value1', 'Value2'))
sql_2= "INSERT INTO
T2
(V3
,V4
) values(%s, %s)"cur.execute(sql_2, ('Value3', 'Value4'))
conn.commit()
The text was updated successfully, but these errors were encountered: