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})