-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.py
executable file
·48 lines (30 loc) · 1.01 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# import logging
# logging.basicConfig(level=logging.INFO)
# import asyncio,os,json,time
# from datetime import datetime
# from aiohttp import web
# def index(request):
# return web.Response(body=b'<h1>sunshuai</h1>',content_type='text/html')
# @asyncio.coroutine
# def init(loop):
# app=web.Application(loop=loop)
# app.router.add_route('GET','/',index)
# srv=yield from loop.create_server(app.make_handler(),'127.0.0.1',9000)
# logging.info('server started at http://127.0.0.1:9000....')
# return srv
# loop=asyncio.get_event_loop()
# loop.run_until_complete(init(loop))
# loop.run_forever()
import orm
from models import User,Blog,Comment
import logging
logging.basicConfig(level=logging.INFO)
import asyncio,os,json,time
async def test(loop):
await orm.create_pool(loop=loop,user='root',password='root',db='db')
u= User(name='Test',email='[email protected]',passwd='113231231')
logging.info(u,'user')
await u.save()
loop = asyncio.get_event_loop()
loop.run_until_complete(test(loop))
loop.close()