From 92b2af570bdae55bea65cb6a8d7483e36b90f94b Mon Sep 17 00:00:00 2001 From: ericssonmarin-cpp <85146518+ericssonmarin-cpp@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:26:19 -0700 Subject: [PATCH] Markets transactions. --- MarketPlaces/DB_Connection/db_connection.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MarketPlaces/DB_Connection/db_connection.py b/MarketPlaces/DB_Connection/db_connection.py index 46c05cd..03de3d2 100644 --- a/MarketPlaces/DB_Connection/db_connection.py +++ b/MarketPlaces/DB_Connection/db_connection.py @@ -29,6 +29,8 @@ def verifyMarketPlace(cur, nameMarket): try: + cur.execute("lock table marketPlaces IN ACCESS EXCLUSIVE MODE") + cur.execute("select market_id from marketPlaces where name_market = %(nameMarket)s limit 1", {'nameMarket': nameMarket}) recset = cur.fetchall() @@ -48,6 +50,8 @@ def verifyVendor(cur, nameVendor, marketId): try: + cur.execute("lock table vendors IN ACCESS EXCLUSIVE MODE") + cur.execute("select vendor_id from vendors where name_vendor = %(nameVendor)s and market_id = %(marketId)s " "limit 1", {'nameVendor': nameVendor, 'marketId': marketId}) @@ -67,6 +71,8 @@ def verifyItem(cur, marketId, vendorId, nameItem): try: + cur.execute("lock table items IN ACCESS EXCLUSIVE MODE") + cur.execute("select item_id from items where market_id = %(marketId)s and vendor_id = %(vendorId)s and name_item = %(nameItem)s" "limit 1", {'marketId': marketId, 'vendorId': vendorId, 'nameItem': nameItem})