Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from contextlib import contextmanager
- class A:
- @contextmanager
- def transaction(self, isolation_level="DEFERRED"):
- prev_iso_lvl = self.conn.isolation_level
- self.conn.isolation_level = "DEFERRED"
- self.conn.execute("BEGIN")
- yield
- self.conn.commit()
- self.conn.isolation_level = prev_iso_lvl
- def insert_many(self, users, users_data):
- with self.transaction():
- for user in users:
- data = users_data[user['username']]
- self.insert(user, data) # !!!
- def insert_many(self, users, users_data):
- with self.transaction():
- for user in users:
- data = users_data[user['username']]
- self.update(user, data) # !!!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement