SHARE
TWEET

Untitled

a guest Jun 25th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. engine = create_engine('postgresql://postgres:passw0rd@localhost:5432/mini_amazon')
  2.     Session = sessionmaker(bind=engine, expire_on_commit=False)
  3.  
  4.     @contextmanager
  5.     def session_scope():
  6.         """
  7.         Provide a transactional scope around a series of operations.
  8.         """
  9.         session = Session()
  10.         try:
  11.             yield session
  12.             session.commit()
  13.         except:
  14.             session.rollback()
  15.             raise
  16.         finally:
  17.             session.close()
  18.  
  19.     with session_scope() as session:
  20.         while True:
  21.             print('Waiting')
  22.             order = session.query(models.Order).get(arrived_message.packageid)
  23.             time.sleep(1)
  24.             if order.status == 'packed':
  25.                 break
  26.  
  27.         order.status = 'loading'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top