本文整理汇总了Python中orm.create_pool方法的典型用法代码示例。如果您正苦于以下问题:Python orm.create_pool方法的具体用法?Python orm.create_pool怎么用?Python orm.create_pool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类orm
的用法示例。
在下文中一共展示了orm.create_pool方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
# ????????
await orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='www', password='www', db='awesome')
# ??app???????????????middlewares
app = web.Application(loop=loop, middlewares=[
logger_factory, auth_factory, response_factory
])
# ???jinja2???????????
init_jinja2(app, filters=dict(datetime=datetime_filter))
# ????????coroweb???
add_routes(app, 'handlers') # handlers???handlers?????handlers.py
add_static(app)
srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
logging.info('server started at http://127.0.0.1:9000...')
return srv
# asyncio????????????????????asyncio?????????eventloop??????????//
# ????????????eventloop??????????IO
# ??????eventloop
# get_event_loop()????python????18.5.2.5
# get_event_loop() => ?????????????????event loop??(????????'asyncio.windows_events._WindowsSelectorEventLoop')???AbstractEventLoop???????????
# ????????????????????get_event_loop()??????None
示例2: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
app_port = 8080
database_port = 3306
host = '127.0.0.1'
yield from orm.create_pool(
loop=loop,
host=host,
port=database_port,
user='root',
password='czh',
db='weppy'
)
app = web.Application(loop=loop, middlewares=[
logger_factory, response_factory, auth_factory
])
init_jinja2(app,)
add_routes(app, 'apis')
add_routes(app, 'blog')
add_routes(app, 'controller')
add_static(app)
srv = yield from loop.create_server(app.make_handler(), host, app_port)
logging.info('server started at {}:{}...'.format(host, app_port))
return srv
示例3: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
# ????????
await orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='root', password='123456', db='awesome')
# ??app???????????????middlewares
app = web.Application(loop=loop, middlewares=[
logger_factory, auth_factory, response_factory
])
# ???jinja2???????????
init_jinja2(app, filters=dict(datetime=datetime_filter))
# ????????coroweb???
add_routes(app, 'handlers') # handlers???handlers?????handlers.py
add_static(app)
srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
logging.info('server started at http://127.0.0.1:9000...')
return srv
# asyncio????????????????????asyncio?????????eventloop??????????//
# ????????????eventloop??????????IO
# ??????eventloop
# get_event_loop()????python????18.5.2.5
# get_event_loop() => ?????????????????event loop??(????????'asyncio.windows_events._WindowsSelectorEventLoop')???AbstractEventLoop???????????
# ????????????????????get_event_loop()??????None
示例4: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
await orm.create_pool(loop=loop,**configs.db)
app = web.Application(loop=loop,middlewares=[logger_factory,auth_factory,response_factory])
init_jinja2(app,filters=dict(datetime=datetime_filter))
add_routes(app,'handlers')
add_static(app)
srv = await loop.create_server(app.make_handler(),'127.0.0.1',9000)
logging.info('server started at http://127.0.0.1:9000...')
return srv
示例5: connecDB
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def connecDB(loop):
username = 'root'
password = 'root'
dbname = 'pydb'
await orm.create_pool(loop,user=username,password=password,db=dbname)
示例6: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
#app = web.Application(loop = loop, host = '127.0.0.1', port = 3306, user = 'root', password = '123', database = 'awesome')
yield from orm.create_pool(loop = loop, host = '127.0.0.1', port = 3306, user = 'root', password = '123', database = 'awesome')
app = web.Application(loop = loop, middlewares = [
logger_factory, auth_factory, response_factory
])
init_jinja2(app, filters = dict(datetime = datetime_filter))
add_routes(app, 'handlers')
add_static(app)
#app.router.add_route('GET', '/', index)
srv = yield from loop.create_server(app.make_handler(), '::', 8080)
logging.info('Server started at http://127.0.0.1:8080...')
return srv
示例7: test
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def test():
yield from orm.create_pool(loop, host='127.0.0.1', port = 3306, user='root', password='123', database='awesome')
u = User(name='Test', email = '[email protected]', password = '123', image = 'about:blank')
yield from u.save()
#yield from orm.destory_pool()
示例8: test
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def test(loop):
await orm.create_pool(loop=loop,user='www-data', password='www-data', db='awesome')
u=User(name='test20',email='[email protected]',passwd='test',image='about:blank')
await u.save()
示例9: find
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def find():
await orm.create_pool(loop, user='root', password='password', db='awesome')
all = await User.findAll()
print(all)
pk = await User.find('00149276202953187d8d3176f894f1fa82d9caa7d36775a000')
print(pk)
num = await User.findNumber('email')
print(num)
await orm.destory_pool()
示例10: test
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def test():
yield from orm.create_pool(loop, user='root', password='czh', db='weppy')
user = User(name="admin", password='123', is_admin=True)
yield from user.save()
yield from orm.destory_pool()
示例11: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
# await orm.create_pool(loop=loop, host='127.0.0.1', port=3306, user='root', password='1qazxsw2', db='awesome')
await orm.create_pool(loop=loop, **configs.db)
app = web.Application(loop=loop, middlewares=[
logger_factory, auth_factory, response_factory
])
init_jinja2(app, filters=dict(datetime=datetime_filter))
add_routes(app, 'handlers')
add_static(app)
srv = await loop.create_server(app.make_handler(), '127.0.0.1', 9000)
logging.info('server started at http://127.0.0.1:9000...')
return srv
示例12: init
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def init(loop):
'''
???web???.
'''
await orm.create_pool(loop = loop, **configs.db)
app = web.Application(loop = loop, middlewares = [
logger_factory, auth_factory, response_factory
])
# filters??????jinja2?????
init_jinja2(app, filters = dict(datetime = datetime_filter))
add_routes(app, 'handlers')
add_static(app)
srv = await loop.create_server(app.make_handler(), '0.0.0.0', 9000)
logging.info('server start at http://127.0.0.1:9000...')
return srv
示例13: test
# 需要导入模块: import orm [as 别名]
# 或者: from orm import create_pool [as 别名]
def test(loop):
'''
Test orm framewoek.
'''
yield from orm.create_pool(loop=loop,user = 'www-data', password = 'www-data', db = 'awesome')
user = User(id='ni',name = 'Coco Shi',email = '[email protected]', passwd = '102033', image = 'blank')
yield from user.save()