Debian Codegraph @

examples/example_callproc_oldstyle.py

raw
1 import asyncio
2 import aiomysql
3
4
5 loop = asyncio.get_event_loop()
6
7
8 @asyncio.coroutine
9 def test_example():
10 conn = yield from aiomysql.connect(host='127.0.0.1', port=3306,
11 user='root', password='',
12 db='test_pymysql', loop=loop)
13
14 cur = yield from conn.cursor()
15 yield from cur.execute("DROP PROCEDURE IF EXISTS myinc;")
16 yield from cur.execute("""CREATE PROCEDURE myinc(p1 INT)
17 BEGIN
18 SELECT p1 + 1;
19 END
20 """)
21
22 yield from cur.callproc('myinc', [1])
23 (ret, ) = yield from cur.fetchone()
24 assert 2, ret
25 print(ret)
26
27 yield from cur.close()
28 conn.close()
29
30
31 loop.run_until_complete(test_example())