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


Python DB.init_pool方法代碼示例

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


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

示例1: setUpClass

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import init_pool [as 別名]
	def setUpClass(cls):

		app.config['DATABASE'] = config.connstr
		app.config['TESTING'] = True

		DB.init_pool(app.config['DATABASE'])

		with DB(False) as (conn, cursor):

			# this pretty much cascades to everything, except animals
			cursor.execute("TRUNCATE users CASCADE")

			# create a single user/distribution/version
			cursor.execute("INSERT INTO users (user_name, full_name) VALUES ('test_user', 'test user full name')")
			cursor.execute("INSERT INTO distributions (user_id, dist_name) VALUES (currval('users_id_seq'), 'testdistr')")
			cursor.execute("INSERT INTO distribution_versions (dist_id, dist_version, dist_date, dist_status) VALUES (currval('distributions_id_seq'), '1.2.3', '2014-01-02 03:04:05', 'stable')")

			cursor.execute("INSERT INTO users (user_name, full_name) VALUES ('test_user2', 'test user full name')")
			cursor.execute("INSERT INTO distributions (user_id, dist_name) VALUES (currval('users_id_seq'), 'testdistr2')")
			cursor.execute("INSERT INTO distribution_versions (dist_id, dist_version, dist_date, dist_status) VALUES (currval('distributions_id_seq'), '1.2.4', '2014-01-02 03:04:05', 'stable')")

			cursor.execute("INSERT INTO users (user_name, full_name) VALUES ('test_user3', 'test user full name')")
			cursor.execute("INSERT INTO distributions (user_id, dist_name) VALUES (currval('users_id_seq'), 'testdistr3')")
			cursor.execute("INSERT INTO distribution_versions (dist_id, dist_version, dist_date, dist_status) VALUES (currval('distributions_id_seq'), '1.2.5', '2014-01-02 03:04:05', 'stable')")

			conn.commit()
開發者ID:tvondra,項目名稱:pgxn-tester-server,代碼行數:28,代碼來源:distribution_tests.py

示例2: setUpClass

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import init_pool [as 別名]
	def setUpClass(cls):

		app.config['DATABASE'] = config.connstr
		app.config['TESTING'] = True

		DB.init_pool(app.config['DATABASE'])

		with DB(False) as (conn, cursor):

			# this pretty much cascades to everything, except animals
			cursor.execute("TRUNCATE animals CASCADE")

			conn.commit()
開發者ID:tvondra,項目名稱:pgxn-tester-server,代碼行數:15,代碼來源:animal_tests.py

示例3: Flask

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import init_pool [as 別名]
from flask.ext.restful import Api

# this is where the implementation is placed
sys.path.append('src')

from db import DB
import cors, jsonp

# create flask application
app = Flask(__name__)

# load config from the config.api dictionary
app.config.from_object('config.api')

# initialize the database pool
DB.init_pool(app.config['DATABASE'])

# create the REST api
api = Api(app)

# CORS / allow calls from all origins (well, especially pgxn-tester.org, but not only)
api.decorators=[cors.crossdomain(origin='*'), jsonp.support_jsonp]

import index
import distributions
import users
import machines
import results
import stats

api.add_resource(index.Index, '/')
開發者ID:tvondra,項目名稱:pgxn-tester-server,代碼行數:33,代碼來源:server-api.py


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