當前位置: 首頁>>代碼示例>>Python>>正文


Python DB.add方法代碼示例

本文整理匯總了Python中db.DB.add方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.add方法的具體用法?Python DB.add怎麽用?Python DB.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在db.DB的用法示例。


在下文中一共展示了DB.add方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: index

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add [as 別名]
def index():
	'''
	The only view we have. All in one page, where we check if user GETs or POSTs.
	If user is POSTing we create a single list and append each from element into it.
	Very important here is the sequence, since we are using it in the DB api.
	When we get all data from the user we execute same procedure we do in GET:
	- get all data and render out main html with it.
	'''
	api = DB()
	if request.method == 'POST':
		new_movie = []
		_title = request.form.get('title')
		new_movie.append(_title)
		_story = request.form.get('story')
		new_movie.append(_story)
		_poster = request.form.get('poster')
		new_movie.append(_poster)
		_trailer = request.form.get('trailer')
		new_movie.append(_trailer)
		_cast = request.form.get('cast')
		new_movie.append(_cast)
		api.add(new_movie)
		result = api.get_data()
		return render_template("index.html", pname=pname, result=result)
	result = api.get_data()
	return render_template("index.html", pname=pname, result=result)
開發者ID:rbagrov,項目名稱:Trailer-preview,代碼行數:28,代碼來源:main.py

示例2: bruteforce_order

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add [as 別名]
def bruteforce_order(d, limit=5, min=0, max=3, feed=None):
    """
    Considers monic polynomials with the rest coefficients between min and max
    adds to the database upto limit (counting already existing ones)
    
    """

    db = DB()

    for c in all_coeffs(d, min, max, feed):
        c.append(1)  # Monic polynomials
        f = make_polynomial(c)

        if f.is_irreducible():
            g = f.galois_group()
            print f, "(", g._n, ")"

            if len(db.list(d, g._n)) < limit:
                print "Added", f, "(", g._n, ")"
                db.add(f)

    return None
開發者ID:barumrho,項目名稱:sage_polynomial,代碼行數:24,代碼來源:bruteforce.py

示例3: bruteforce_random

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import add [as 別名]
def bruteforce_random(d, limit=1, record=False, min=-100, max=100):
    db = DB()

    tried = 0
    tried_hundred = 0
    found = 0

    while found < limit:
        f = irreducible_polynomial(d)
        if test_discriminant(f):
            print
            print "Tried:", tried, "polynomials"
            print "f(x) =", f
            if record:
                db.add(f)
      
            found += 1
    
        tried += 1
        if tried_hundred != int(tried / 100):
            print >> sys.stderr, tried, 
            tried_hundred = int(tried / 100)

    return f
開發者ID:barumrho,項目名稱:sage_polynomial,代碼行數:26,代碼來源:bruteforce.py


注:本文中的db.DB.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。