本文整理匯總了Python中models.Stock.select方法的典型用法代碼示例。如果您正苦於以下問題:Python Stock.select方法的具體用法?Python Stock.select怎麽用?Python Stock.select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Stock
的用法示例。
在下文中一共展示了Stock.select方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: buyer
# 需要導入模塊: from models import Stock [as 別名]
# 或者: from models.Stock import select [as 別名]
def buyer():
stocks = Stock.select().where(Stock.bought == False)
stocks = [
{"id": json.dumps(str(stock.id)), "stock": stock} for stock in stocks
] # this will be used for adding listings to the homepage
tags = [product.name for product in Product.select()]
tags += [descriptor.description for descriptor in Descriptor.select()]
tags += [brand.name for brand in Brand.select()]
tags.sort()
return render_template("buyer_dashboard.html", stocks=stocks, Order=Order, Stock=Stock, tags=tags, fn=fn)
示例2: test_create_stock
# 需要導入模塊: from models import Stock [as 別名]
# 或者: from models.Stock import select [as 別名]
def test_create_stock(self):
"""Make sure it create a stock."""
Category.create(category_id='001', description='Testing Stock')
create_stock('001', 'Testing stock', 1, '001', 9.99)
s = Stock.select().where(Stock.stock_id == '001')
t = Stock.delete().where(Stock.stock_id == '001')
t.execute()
t = Category.delete().where(Category.category_id == '001')
t.execute()
self.assertEqual(str(s), ("<class 'models.Stock'> SELECT `t1`.`id`,"
" `t1`.`stock_id`, `t1`.`description`,"
" `t1`.`quantity`, `t1`.`category_id`,"
" `t1`.`price` FROM `stock` AS t1"
" WHERE (`t1`.`stock_id` = %s) ['001']"))
示例3: test_create_incoming
# 需要導入模塊: from models import Stock [as 別名]
# 或者: from models.Stock import select [as 別名]
def test_create_incoming(self):
"""Create an incoming record."""
Category.create(category_id='001', description='Testing Stock')
create_stock('001', 'Testing stock', 1, '001', 9.99)
create_incoming_stock(stock="001", date="2015-07-22", quantity=13, price=13.99)
p = IncomingStock.select().where(IncomingStock.stock == '001')
q = IncomingStock.delete().where(IncomingStock.stock == '001')
q.execute()
s = Stock.select().where(Stock.stock_id == '001')
t = Stock.delete().where(Stock.stock_id == '001')
t.execute()
t = Category.delete().where(Category.category_id == '001')
t.execute()
self.assertEqual(str(p), ("<class 'models.IncomingStock'> SELECT `t1`.`id`, `t1`.`stock_id`, "
"`t1`.`date`, `t1`.`price`, `t1`.`cost` FROM `incomingstock` AS t1 WHERE "
"(`t1`.`stock_id` = %s) ['001']"))
示例4: stock_id_exists
# 需要導入模塊: from models import Stock [as 別名]
# 或者: from models.Stock import select [as 別名]
def stock_id_exists(form, field):
"""Check if the stock id exists."""
if Stock.select().where(Stock.stock_id == field.data).exists():
raise ValidationError("Stock ID already exists, use a different one.")