Example #1
0
def init_db():
	with app.app_context():
		setup_db()
		with app.open_resource('schema.sql', mode='r') as f:
			g.db.executescript(f.read())
		g._db.commit()
		close_db(None)
Example #2
0
 def do_transactions(self, copies, user, product, date=datetime.now(), notes='', price=1.0):
     """ Add a transaction at a specific date, with optional notes. """
 	with app.app_context():
         streck.models.setup_db()
         price = product.price() or price
         for _ in range(copies):
             g.db.execute('insert into transactions values (null, ?, ?, ?, ?, ?)', [date.isoformat(), user.id(), product.id(), price, notes])
         g._db.commit()
         streck.models.close_db(None)
Example #3
0
 def do_transactions(self,
                     copies,
                     user,
                     product,
                     date=datetime.now(),
                     notes='',
                     price=1.0):
     """ Add a transaction at a specific date, with optional notes. """
     with app.app_context():
         streck.models.setup_db()
         price = product.price() or price
         for _ in range(copies):
             g.db.execute(
                 'insert into transactions values (null, ?, ?, ?, ?, ?)',
                 [date.isoformat(),
                  user.id(),
                  product.id(), price, notes])
         g._db.commit()
         streck.models.close_db(None)